Module Grape::DSL::InsideRoute
In: lib/grape/dsl/inside_route.rb

Methods

Included Modules

Grape::DSL::Settings Grape::DSL::Headers

Classes and Modules

Module Grape::DSL::InsideRoute::PostBeforeFilter
Class Grape::DSL::InsideRoute::MethodNotYetAvailable

Public Class methods

@param type [Symbol] The type of filter for which evaluation has been

  completed

@return [Module] A module containing method overrides suitable for the

  position in the filter evaluation sequence denoted by +type+.  This
  defaults to an empty module if no overrides are defined for the given
  filter +type+.

Public Instance methods

Allows you to define the response body as something other than the return value.

@example

  get '/body' do
    body "Body"
    "Not the Body"
  end

  GET /body # => "Body"

Set response content-type

Set or get a cookie

@example

  cookies[:mycookie] = 'mycookie val'
  cookies['mycookie-string'] = 'mycookie string val'
  cookies[:more] = { value: '123', expires: Time.at(0) }
  cookies.delete :more

A filtering method that will return a hash consisting only of keys that have been declared by a `params` statement against the current/target endpoint or parent namespaces.

@see +PostBeforeFilter#declared+

@param params [Hash] The initial hash to filter. Usually this will just be `params` @param options [Hash] Can pass `:include_missing`, `:stringify` and `:include_parent_namespaces` options. `:include_parent_namespaces` defaults to true, hence must be set to false if you want only to return params declared against the current/target endpoint.

Attempt to locate the Entity class for a given object, if not given explicitly. This is done by looking for the presence of Klass::Entity, where Klass is the class of the `object` parameter, or one of its ancestors. @param object [Object] the object to locate the Entity class for @param options [Hash] @option options :with [Class] the explicit entity class to use @return [Class] the located Entity class, or nil if none is found

@return the representation of the given object as done through

  the given entity_class.

End the request and display an error to the end user with the specified message.

@param message [String] The message to display. @param status [Integer] the HTTP Status Code. Defaults to default_error_status, 500 if not set.

Allows you to define the response as a file-like object.

@example

  get '/file' do
    file FileStreamer.new(...)
  end

  GET /file # => "contents of file"

Allows you to make use of Grape Entities by setting the response body to the serializable hash of the entity provided in the `:with` option. This has the added benefit of automatically passing along environment and version information to the serialization, making it very easy to do conditional exposures. See Entity docs for more info.

@example

  get '/users/:id' do
    present User.find(params[:id]),
      with: API::Entities::User,
      admin: current_user.admin?
  end

Redirect to a new url.

@param url [String] The url to be redirect. @param options [Hash] The options used when redirect.

                      :permanent, default false.
                      :body, default a short message including the URL.

Allows you to explicitly return no content.

@example

  delete :id do
    return_no_content
    "not returned"
  end

  DELETE /12 # => 204 No Content, ""

Returns route information for the current request.

@example

  desc "Returns the route description."
  get '/' do
    route.description
  end

Set or retrieve the HTTP status code.

@param status [Integer] The HTTP Status Code to return for this request.

Allows you to define the response as a streamable object.

If Content-Length and Transfer-Encoding are blank (among other conditions), Rack assumes this response can be streamed in chunks.

@example

  get '/stream' do
    stream FileStreamer.new(...)
  end

  GET /stream # => "chunked contents of file"

See:

The API version as specified in the URL.

[Validate]