Method: Hanami::API.mount

Defined in:
lib/hanami/api.rb

.mountObject

Mount a Rack application at the specified path. All the requests starting with the specified path, will be forwarded to the given application.

All the other methods (eg #get) support callable objects, but they restrict the range of the acceptable HTTP verb. Mounting an application with #mount doesn’t apply this kind of restriction at the router level, but let the application to decide.

Examples:

require "hanami/api"

class MyAPI < Hanami::API
  mount MyRackApp.new, at: "/foo"
end

Parameters:

  • app (#call)

    a class or an object that responds to #call

  • at (String)

    the relative path where to mount the app

  • constraints (Hash)

    a set of constraints for path variables

Since:

  • 0.1.0



318
319
320
# File 'lib/hanami/api.rb', line 318

def self.mount(...)
  @router.mount(...)
end