Liking cljdoc? Tell your friends :D

puppetlabs.puppetdb.middleware

Ring middleware

Ring middleware
raw docstring

build-allowlist-authorizerclj

(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.
sourceraw docstring

cause-finderclj

(cause-finder ex)
source

consume-and-closeclj

(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
sourceraw docstring

fail-when-payload-too-largeclj

(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
sourceraw docstring

get-sync-verclj

(get-sync-ver)
source

handler-schemaclj

source

http-metrics-registryclj

source

make-pdb-handlerclj

(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.
sourceraw docstring

merge-param-specsclj

(merge-param-specs & specs)
source

params-schemaclj

source

parent-checkclj

(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.
sourceraw docstring

url-decodeclj

(url-decode x)

Inputs: [x :- s/Str] Returns: s/Str

Inputs: [x :- s/Str]
Returns: s/Str
sourceraw docstring

validate-no-query-paramsclj

(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.
sourceraw docstring

validate-query-paramsclj

(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.
sourceraw docstring

verify-content-encodingclj

(verify-content-encoding app allowed-encodings)

Verification for the specified list of content-encodings.

Verification for the specified list of content-encodings.
sourceraw docstring

verify-sync-versionclj

(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.
sourceraw docstring

wrap-cert-authnclj

(wrap-cert-authn app cert-allowlist)
source

wrap-with-certificate-cnclj

(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.
sourceraw docstring

wrap-with-debug-loggingclj

(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"/>`
sourceraw docstring

wrap-with-default-bodyclj

(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.
sourceraw docstring

wrap-with-exception-handlingclj

(wrap-with-exception-handling app)
source

wrap-with-globalsclj

(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.
sourceraw docstring

wrap-with-illegal-argument-catchclj

(wrap-with-illegal-argument-catch app)
source

wrap-with-metricsclj

(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 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 '_'.

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 '_'.
sourceraw docstring

wrap-with-puppetdb-middlewareclj

(wrap-with-puppetdb-middleware app)

Default middleware for puppetdb webservers.

Default middleware for puppetdb webservers.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close