Ring middleware
Ring middleware
(build-allowlist-authorizer allowlist)Build a function that will authorize requests based on the supplied
certificate allowlist (see cn-whitelist->authorizer for more
details). Returns :authorized if the request is allowed, otherwise a
string describing the reason not.
Build a function that will authorize requests based on the supplied certificate allowlist (see `cn-whitelist->authorizer` for more details). Returns :authorized if the request is allowed, otherwise a string describing the reason not.
(consume-and-close req-stream content-length)Consume all data from input stream and then close
Consume all data from input stream and then close
(fail-when-payload-too-large app reject-large-commands? max-command-size)Middlware that will return a 413 failure when the content-length of
a POST is too large (more than max-command-size). Acts as a noop
when it is less or `reject-large-commands? is false
Middlware that will return a 413 failure when the content-length of a POST is too large (more than `max-command-size`). Acts as a noop when it is less or `reject-large-commands? is false
(make-pdb-handler route)(make-pdb-handler route handler-fn)Inputs: ([route :- bidi-schema/RoutePair] [route :- bidi-schema/RoutePair handler-fn :- handler-schema]) Returns: handler-schema
Similar to bidi.ring/make-handler but does not merge route-params
into the regular parameter map. Currently route-params causes
validation errors with merged in with parameters. Parameter names
are currently strings and validated against an expected list. Route
params are merged in a keywords.
Inputs: ([route :- bidi-schema/RoutePair] [route :- bidi-schema/RoutePair handler-fn :- handler-schema]) Returns: handler-schema Similar to `bidi.ring/make-handler` but does not merge route-params into the regular parameter map. Currently route-params causes validation errors with merged in with parameters. Parameter names are currently strings and validated against an expected list. Route params are merged in a keywords.
(parent-check app _version parent route-param-key)Middleware that checks the parent exists before serving the rest of the application. This ensures we always return 404's on child paths when the parent data is empty.
Middleware that checks the parent exists before serving the rest of the application. This ensures we always return 404's on child paths when the parent data is empty.
(url-decode x)Inputs: [x :- s/Str] Returns: s/Str
Inputs: [x :- s/Str] Returns: s/Str
(validate-no-query-params app)Ring middleware that verifies that there are no query params on the request. Convenience method for endpoints that do not support any query params. If the validation fails, a 400 Bad Request is returned, with an explanation of the invalid parameters.
Ring middleware that verifies that there are no query params on the request. Convenience method for endpoints that do not support any query params. If the validation fails, a 400 Bad Request is returned, with an explanation of the invalid parameters.
(validate-query-params app param-specs)Inputs: [app param-specs :- params-schema]
Ring middleware that verifies that the query params in the request are legal
based on the map param-specs, which contains a list of :required and
:optional query parameters. If the validation fails, a 400 Bad Request is
returned, with an explanation of the invalid parameters.
Inputs: [app param-specs :- params-schema] Ring middleware that verifies that the query params in the request are legal based on the map `param-specs`, which contains a list of `:required` and `:optional` query parameters. If the validation fails, a 400 Bad Request is returned, with an explanation of the invalid parameters.
(verify-content-encoding app allowed-encodings)Verification for the specified list of content-encodings.
Verification for the specified list of content-encodings.
(verify-sync-version app)Check that the x-pdb-sync-ver header of an incoming requests matches the pdb-sync-ver locally. This header is only sent from pe-puppetdb sync requests and a mismatch indicates that one pdb has upgraded in an incompatible way before the other. In this case all sync requests will return 409s until both sides have been upgraded and have matching sync versions. If the header is present but improperly formatted returns a 400 error response.
Check that the x-pdb-sync-ver header of an incoming requests matches the pdb-sync-ver locally. This header is only sent from pe-puppetdb sync requests and a mismatch indicates that one pdb has upgraded in an incompatible way before the other. In this case all sync requests will return 409s until both sides have been upgraded and have matching sync versions. If the header is present but improperly formatted returns a 400 error response.
(wrap-with-certificate-cn app)Ring middleware that will annotate the request with an :ssl-client-cn key representing the CN contained in the client certificate of the request. If no client certificate is present, the key's value is set to nil.
Ring middleware that will annotate the request with an :ssl-client-cn key representing the CN contained in the client certificate of the request. If no client certificate is present, the key's value is set to nil.
(wrap-with-debug-logging app)Ring middleware that logs incoming HTTP request URIs (at DEBUG level) as requests come in. To enable, add this line to your logback.xml:
<logger name="puppetlabs.puppetdb.middleware" level="debug"/>
Ring middleware that logs incoming HTTP request URIs (at DEBUG level) as requests come in. To enable, add this line to your logback.xml: `<logger name="puppetlabs.puppetdb.middleware" level="debug"/>`
(wrap-with-default-body app)Ring middleware that will attach a default body based on the response code if no other body is supplied.
Ring middleware that will attach a default body based on the response code if no other body is supplied.
(wrap-with-globals app get-shared-globals)Ring middleware that adds a :globals attribute to each request that contains a map of the current shared-global settings.
Ring middleware that adds a :globals attribute to each request that contains a map of the current shared-global settings.
(wrap-with-metrics app storage normalize-uri)Ring middleware that will tack performance counters for each URL. We track the following metrics per-app, at a top-level
service-time: how long it took to service the requestWe track the following meters per-app, and per-response-code:
reqs/s: the rate at which responses of a given status are
reportedCreated metrics are stored in the supplied storage atom with the
following structure:
{:timers {<normalized uri> <service time metric>
<normalized uri> <service time metric>}
:meters {<normalized uri> {<status code> <reqs/s>
<status code> <reqs/s>}}}
app: The ring app to be wrapped
storage: An atom that will be used to hold references to all
created metrics.
normalize-uri: A function that takes a URI, and returns a string
or collection of strings. For each string returned, a timer and
meter will be created if they don't already exist. To have multiple
URLs share the same timer/meter, normalize-uri should return some
of the same strings for each URL.
Metric names (and thus, the strings returned by normalize-uri
cannot contain ':', '=', or ',' characters. They will be replaced
with '_'.
Ring middleware that will tack performance counters for each URL.
We track the following metrics per-app, at a top-level
* `service-time`: how long it took to service the request
We track the following meters per-app, and per-response-code:
* `reqs/s`: the rate at which responses of a given status are
reported
Created metrics are stored in the supplied `storage` atom with the
following structure:
{:timers {<normalized uri> <service time metric>
<normalized uri> <service time metric>}
:meters {<normalized uri> {<status code> <reqs/s>
<status code> <reqs/s>}}}
`app`: The ring app to be wrapped
`storage`: An atom that will be used to hold references to all
created metrics.
`normalize-uri`: A function that takes a URI, and returns a string
or collection of strings. For each string returned, a timer and
meter will be created if they don't already exist. To have multiple
URLs share the same timer/meter, `normalize-uri` should return some
of the same strings for each URL.
Metric names (and thus, the strings returned by `normalize-uri`
cannot contain ':', '=', or ',' characters. They will be replaced
with '_'.(wrap-with-puppetdb-middleware app)Default middleware for puppetdb webservers.
Default middleware for puppetdb webservers.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |