Class: ForestAdminRpcAgent::Routes::Schema
- Includes:
- ForestAdminAgent::Routes::QueryHandler, ForestAdminAgent::Utils, ForestAdminDatasourceToolkit::Components::Query::ConditionTree
- Defined in:
- lib/forest_admin_rpc_agent/routes/schema.rb
Constant Summary collapse
- HTTP_OK =
200- HTTP_NOT_MODIFIED =
304
Instance Method Summary collapse
- #handle_request(args) ⇒ Object
-
#initialize ⇒ Schema
constructor
A new instance of Schema.
Methods inherited from BaseRoute
#build_rails_response, #register_rails, #register_sinatra, #registered
Constructor Details
#initialize ⇒ Schema
Returns a new instance of Schema.
11 12 13 |
# File 'lib/forest_admin_rpc_agent/routes/schema.rb', line 11 def initialize super('rpc-schema', 'get', 'rpc_schema') end |
Instance Method Details
#handle_request(args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/forest_admin_rpc_agent/routes/schema.rb', line 15 def handle_request(args) agent = ForestAdminRpcAgent::Agent.instance client_etag = extract_if_none_match(args) # If client has cached schema and ETag matches, return 304 Not Modified if client_etag && agent.schema_hash_matches?(client_etag) ForestAdminRpcAgent::Facades::Container.logger.log( 'Debug', 'ETag matches, returning 304 Not Modified' ) return { status: HTTP_NOT_MODIFIED, content: nil, headers: { 'ETag' => quote_etag(agent.cached_schema_hash) } } end # Get schema from cache (or build from datasource if not cached) schema = agent.rpc_schema etag = agent.cached_schema_hash # Return schema with ETag header { status: HTTP_OK, content: schema, headers: { 'ETag' => quote_etag(etag) } } end |