Class: RestCore::DefaultQuery

Inherits:
Object
  • Object
show all
Includes:
Middleware
Defined in:
lib/rest-core/middleware/default_query.rb

Constant Summary

Constant Summary

Constants included from Middleware

Middleware::UNRESERVED

Constants included from RestCore

ASYNC, CLIENT, DRY, FAIL, HIJACK, LOG, PROMISE, REQUEST_HEADERS, REQUEST_METHOD, REQUEST_PATH, REQUEST_PAYLOAD, REQUEST_QUERY, REQUEST_URI, RESPONSE_BODY, RESPONSE_HEADERS, RESPONSE_KEY, RESPONSE_SOCKET, RESPONSE_STATUS, TIMER, Universal, VERSION

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Middleware

contain_binary?, escape, #fail, #id, included, #log, percent_encode, request_uri, #run, string_keys

Methods included from RestCore

eagerload, id

Constructor Details

- (DefaultQuery) initialize(*args)



8
9
10
11
# File 'lib/rest-core/middleware/default_query.rb', line 8

def initialize *args
  super
  @query ||= {}
end

Class Method Details

+ (Object) members



5
# File 'lib/rest-core/middleware/default_query.rb', line 5

def self.members; [:query]; end

Instance Method Details

- (Object) call(env, &k)



13
14
15
16
17
18
# File 'lib/rest-core/middleware/default_query.rb', line 13

def call env, &k
  defaults = string_keys(@query).merge(string_keys(query(env)))

  app.call(env.merge(REQUEST_QUERY =>
    defaults.merge(env[REQUEST_QUERY])), &k)
end