From 3d48a2fbf766120526a39cf2b96189d6c9a8993e Mon Sep 17 00:00:00 2001 From: Christian Trosclair Date: Wed, 22 Jun 2016 22:38:48 -0500 Subject: [PATCH] Create grape integration documentation. --- docs/howto/grape_integration.md | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 docs/howto/grape_integration.md diff --git a/docs/howto/grape_integration.md b/docs/howto/grape_integration.md new file mode 100644 index 00000000..a5cd3675 --- /dev/null +++ b/docs/howto/grape_integration.md @@ -0,0 +1,40 @@ +The AMS grape formatter relies on the existence of `env['grape.request']` which is implemeted by `Grape::Middleware::Globals`. You can meet his dependency by calling it before mounting the endpoints. + +In the simpliest way: + +``` +class API < Grape::API + # @note Make sure this is above you're first +mount+ + use Grape::Middleware::Globals +end +``` + +or more like what is shown in current Grape tutorials: + +``` +module MyApi + class ApiBase < Grape::API + use Grape::Middleware::Globals + + require 'grape/active_model_serializers' + include Grape::ActiveModelSerializers + + mount MyApi::V1::ApiBase + end +end +``` + +You could meet this dependency with your own middleware. The invocation might look like: + +``` +module MyApi + class ApiBase < Grape::API + use My::Middleware::Thingamabob + + require 'grape/active_model_serializers' + include Grape::ActiveModelSerializers + + mount MyApi::V1::ApiBase + end +end +```