Class: Jsonatra::Base
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Jsonatra::Base
- Defined in:
- lib/jsonatra.rb
Class Method Summary collapse
- .get(*args, &block) ⇒ Object
-
.sinatra_get ⇒ Object
because some parameters can be too large for normal GET query strings, all GET routes also accept a POST with body data, with the same parameter names and behavior.
Instance Method Summary collapse
-
#call!(env) ⇒ Object
copied here so we can override Response.new with Jsonatra::Response.new.
Class Method Details
.get(*args, &block) ⇒ Object
118 119 120 121 |
# File 'lib/jsonatra.rb', line 118 def get(*args, &block) sinatra_get *args, &block post *args, &block end |
.sinatra_get ⇒ Object
because some parameters can be too large for normal GET query strings, all GET routes also accept a POST with body data, with the same parameter names and behavior
117 |
# File 'lib/jsonatra.rb', line 117 alias_method :sinatra_get, :get |
Instance Method Details
#call!(env) ⇒ Object
copied here so we can override Response.new with Jsonatra::Response.new
github.com/sinatra/sinatra/blob/master/lib/sinatra/base.rb#L880
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/jsonatra.rb', line 25 def call!(env) # :nodoc: @env = env @request = ::Sinatra::Request.new(env) @response = ::Jsonatra::Response.new @params = indifferent_params(@request.params) template_cache.clear if settings.reload_templates force_encoding(@params) @response['Content-Type'] = nil invoke { dispatch! } invoke { error_block!(response.status) } unless @env['sinatra.error'] unless @response['Content-Type'] if Array === body and body[0].respond_to? :content_type content_type body[0].content_type else content_type :html end end @response.finish end |