Class: Blix::Rest::Context

Inherits:
Struct
  • Object
show all
Defined in:
lib/blix/rest/controller.rb

Overview

base class for controllers. within your block handling a particular route you have access to a number of methods

env : the request environment hash body : the request body as a string body_hash : the request body as a hash constructed from json query_params : a hash of parameters as passed in the url as parameters path_params : a hash of parameters constructed from variable parts of the path params : all the params combined user : the user making this request ( or nil if format : the format the response should be in :json or :html session : the rack session if middleware has been used

to accept requests other thatn json then set :accept=>[:json,:html] as options in the route
  eg  post '/myform' :accept=>[:html]              # this will only accept html requests.

Instance Attribute Summary collapse

Instance Attribute Details

#formatObject

Returns the value of attribute format

Returns:

  • (Object)

    the current value of format



25
26
27
# File 'lib/blix/rest/controller.rb', line 25

def format
  @format
end

#methodObject

Returns the value of attribute method

Returns:

  • (Object)

    the current value of method



25
26
27
# File 'lib/blix/rest/controller.rb', line 25

def method
  @method
end

#paramsObject

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



25
26
27
# File 'lib/blix/rest/controller.rb', line 25

def params
  @params
end

#path_paramsObject

Returns the value of attribute path_params

Returns:

  • (Object)

    the current value of path_params



25
26
27
# File 'lib/blix/rest/controller.rb', line 25

def path_params
  @path_params
end

#reqObject

Returns the value of attribute req

Returns:

  • (Object)

    the current value of req



25
26
27
# File 'lib/blix/rest/controller.rb', line 25

def req
  @req
end

#responseObject

Returns the value of attribute response

Returns:

  • (Object)

    the current value of response



25
26
27
# File 'lib/blix/rest/controller.rb', line 25

def response
  @response
end

#response_optionsObject

Returns the value of attribute response_options

Returns:

  • (Object)

    the current value of response_options



25
26
27
# File 'lib/blix/rest/controller.rb', line 25

def response_options
  @response_options
end

#serverObject

Returns the value of attribute server

Returns:

  • (Object)

    the current value of server



25
26
27
# File 'lib/blix/rest/controller.rb', line 25

def server
  @server
end