You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -4125,35 +4127,36 @@ See [StackOverflow #3282655](http://stackoverflow.com/questions/3282655/ruby-on-
4125
4127
4126
4128
Grape has built-in support for [ActiveSupport::Notifications](http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html) which provides simple hook points to instrument key parts of your application.
4127
4129
4128
-
The following are currently supported:
4129
4130
4130
-
#### endpoint_run.grape
4131
+
#### Hook points
4132
+
The following hook points are currently supported:
4133
+
##### endpoint_run.grape
4131
4134
4132
4135
The main execution of an endpoint, includes filters and rendering.
4133
4136
4134
4137
**endpoint* - The endpoint instance
4135
4138
4136
-
#### endpoint_render.grape
4139
+
#####endpoint_render.grape
4137
4140
4138
4141
The execution of the main content block of the endpoint.
4139
4142
4140
4143
**endpoint* - The endpoint instance
4141
4144
4142
-
#### endpoint_run_filters.grape
4145
+
#####endpoint_run_filters.grape
4143
4146
4144
4147
**endpoint* - The endpoint instance
4145
4148
**filters* - The filters being executed
4146
4149
**type* - The type of filters (before, before_validation, after_validation, after)
4147
4150
4148
-
#### endpoint_run_validators.grape
4151
+
#####endpoint_run_validators.grape
4149
4152
4150
4153
The execution of validators.
4151
4154
4152
4155
**endpoint* - The endpoint instance
4153
4156
**validators* - The validators being executed
4154
4157
**request* - The request being validated
4155
4158
4156
-
#### format_response.grape
4159
+
#####format_response.grape
4157
4160
4158
4161
Serialization or template rendering.
4159
4162
@@ -4162,6 +4165,27 @@ Serialization or template rendering.
4162
4165
4163
4166
See the [ActiveSupport::Notifications documentation](http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html) for information on how to subscribe to these events.
4164
4167
4168
+
#### Subscribe to hooks
4169
+
4170
+
Once subscribed to the instrumentation, you can intercept the events reported above.
4171
+
4172
+
```
4173
+
ActiveSupport::Notifications.subscribe(/<api_path>/) do |name, start, finish, id, payload|
4174
+
# your code to intercept the notification
4175
+
end
4176
+
```
4177
+
4178
+
The request data, the API’s internal data, and the response can be retrieved from the payload.
4179
+
4180
+
You can use `payload.fetch(:endpoint)` or directly `payload[:endpoint]`.
4181
+
4182
+
The `:endpoint` contains the data currently being processed.
4183
+
4184
+
The endpoint provides access to the following attributes:
0 commit comments