RoutesBuilder¶
-
class
eynnyd.routes_builder.
RoutesBuilder
[source]¶ A builder for registering request interceptors, handlers, and response interceptors.
-
add_request_interceptor
(uri_path, interceptor)[source]¶ Adds a request interceptor to be run (before handler execution) given a uri path for when to execute it
- Parameters
uri_path – The path dictating what requests this interceptor is run against
interceptor – A function which takes a request parameter and returns a request
- Returns
This builder to allow fluent design
-
add_response_interceptor
(uri_path, interceptor)[source]¶ Adds a response interceptor to be run (after handler execution) given a uri path for when to execute it
- Parameters
uri_path – The path dictating what requests this interceptor is run against
interceptor – A function which takes a request and a response and returns a response
- Returns
This builder to allow for fluent design
-
add_handler
(http_method, uri_path, handler)[source]¶ Adds a handler to be run (after request interceptors and before response interceptors) given a http method and uri path for when to execute it
- Parameters
http_method – the method to match to execute this handler against a request
uri_path – The path dictating what requests this handler is run against
handler – A function taking a request and returning a response
- Returns
This handler to allow for fluent design
-