-
Notifications
You must be signed in to change notification settings - Fork 3
Create a recipe
Jess edited this page Jul 13, 2016
·
3 revisions
The recipe is a middleware stack which specifies the search methods, in order, to use for a search. It exists as a method on the Whowas module.
First, generate a template:
rails generate whowas:recipe MyRecipe
This will create the following template:
require "middleware"
module Whowas
def self.my_recipe
::Middleware::Builder.new do
# use MySearchMethod1
# use MySearchMethod2
# use MySearchMethod3
end
end
end
The only configuration is to replace the MySearchMethod placeholders with the correct search method classes. In the example above, MySearchMethod1
should take client-supplied input and return an input hash matching the requirements of MySearchMethod2
, which should return an input hash matching the requirements of MySearchMethod3
, and so on. The last middleware (MySearchMethod3
here) should return results to the client.
For more information on middleware and Middleware::Builder in specific, please see Middleware Stacks.