arthurnn / twirp-ruby

Twirp services in Ruby
Apache License 2.0
155 stars 60 forks source link

Add a request_received hook #32

Closed iancanderson closed 5 years ago

iancanderson commented 5 years ago

Closes https://github.com/twitchtv/twirp-ruby/issues/31

This hook is meant to act like the RequestReceived hook in the canonical Go example: https://github.com/twitchtv/twirp/blob/ad6d075411e462f08e971d7efc18f4a770ac8b40/hooks.go#L36-L38

It's not clear to me if the request_received hooks should be called somewhere within route_request or not. For now I'm calling the hooks before the call to route_request, but that might not be what we want? I don't have much experience with Go so I'm struggling to decipher the behavior in the canonical implementation.

marioizquierdo commented 5 years ago

Thank you for the pull request Ian! I'm trying to avoid having to implement a before-request hook, because that would make the logic with the other hooks a little more complicated (specially the on_error hook) and Rack middleware seems to have everything we need to run middleware before the Twirp request is routed. Lets discuss the alternatives in the issue #31 first.

marioizquierdo commented 5 years ago

Closing in favor of using Rack middleware.