Liking cljdoc? Tell your friends :D

io.pedestal.connector

Replacement for io.pedestal.http that is not (directly) linked to the Jakarta Servlet API and is generally simpler to use.

Replacement for io.pedestal.http that is not (directly) linked to the Jakarta Servlet API and is generally
simpler to use.
raw docstring

default-connector-mapclj

(default-connector-map port)
(default-connector-map host port)

Creates a default connector map for the given port and optional host. host defaults to "localhost" which is appropriate for local testing (accessible only from the local host), but "0.0.0.0" (accessible from any TCP/IP connection) is a better option when deployed.

Creates a default connector map for the given port and optional host.  host defaults to "localhost"
which is appropriate for local testing (accessible only from the local host),
but "0.0.0.0" (accessible from any TCP/IP connection) is a better option when deployed.
sourceraw docstring

start!clj

(start! connector)

A convienience function for starting the connector.

This may block the current thread until the connector is stopped.

Returns the connector.

A convienience function for starting the connector.

This may block the current thread until the connector is stopped.

Returns the connector.
sourceraw docstring

stop!clj

(stop! connector)

A convienience function for stopping the connector.

A convienience function for stopping the connector.
sourceraw docstring

with-default-interceptorsclj

(with-default-interceptors connector-map & {:as options})

Sets up a default set of interceptors for early development of an application.

It is expected that an application under active development will not use this function, but will provide its own interceptor stack explicitly.

These interceptors provide basic secure functionality with a limited amount of configurability. Many of the underlying interceptors can be configured for greater security.

A routing interceptor should be added after all other interceptors.

Interceptors (in order):

RoleDescriptionProvided By
Request tracingMake request observable via Open Telemetry[[request-tracing-interceptor]]
Request loggingLog incoming request method and URI[[log-request]]
Allowed origins (optional)Only allow requests from specified origins[[allow-origin]]
Not FoundReport lack of response as a status 404[[not-found]]
Session support (optional)Persist data between requests[[session]]
Body paramsParse JSON, EDN, etc. body into appropriate parameters (:edn-body, :json-body, etc.)[[body-params]]
Cross site request forgeryDetect forged requests[[anti-forgery]]
Default content typeSet response content type from request file extension, if not otherwise set[[content-type]]
Query parametersDecode request :query-string to :query-params[[query-params]]
Secure headersEnsures a number of security-related headers[[secure-headers]]

Note that application code should not depend on the exact names of the interceptors, as those may be subject to change.

OptionNotes
:allowed-originsPassed to [[allow-origin]]
:session-optionsIf non-nil, passed to [[session]]
:extra-mime-typesPassed to [[content-type]]
Sets up a default set of interceptors for _early_ development of an application.

**It is expected that an application under active development will not use this function, but
will provide its own interceptor stack explicitly.**

These interceptors provide basic secure functionality with a limited amount of configurability.
Many of the underlying interceptors can be configured for greater security.

A routing interceptor should be added after all other interceptors.

Interceptors (in order):

Role                       | Description                                   | Provided By
----                       |---                                            |---
Request tracing            | Make request observable via Open Telemetry    | [[request-tracing-interceptor]]
Request logging            | Log incoming request method and URI           | [[log-request]]
Allowed origins (optional) | Only allow requests from specified origins    | [[allow-origin]]
Not Found                  | Report lack of response as a status 404       | [[not-found]]
Session support (optional) | Persist data between requests                 | [[session]]
Body params                | Parse JSON, EDN, etc. body into appropriate  parameters (:edn-body, :json-body, etc.) | [[body-params]]
Cross site request forgery | Detect forged requests                        | [[anti-forgery]]
Default content type       | Set response content type from request file extension, if not otherwise set | [[content-type]]
Query parameters           | Decode request :query-string to :query-params | [[query-params]]
Secure headers             | Ensures a number of security-related headers  | [[secure-headers]]

Note that application code *should not* depend on the exact names of the interceptors, as those may be subject
to change.

Option            | Notes
------            |---
:allowed-origins  | Passed to [[allow-origin]]
:session-options  | If non-nil, passed to [[session]]
:extra-mime-types | Passed to [[content-type]]
sourceraw docstring

with-file-accessclj

(with-file-access connector-map file-path)

Adds an interceptor exposing access to files on the file system, routed at file-path; this uses [[file]]. The URI / maps to the contents of the directory at file-path.

This should be called just before adding a routing interceptor.

This is an alternative to [[file-routes]], and should only be used when file routing would conflict with other routes.

Adds an interceptor exposing access to files on the file system, routed at file-path; this uses
[[file]]. The URI `/` maps to the contents of the directory at `file-path`.

This should be called just before adding a routing interceptor.

This is an alternative to [[file-routes]], and should only be used when file routing would conflict
with other routes.
sourceraw docstring

with-interceptorclj

(with-interceptor connector-map interceptor)

Appends to the :interceptors in the conector map, or does nothing if interceptor is nil.

interceptor must be an interceptor record, or convertable to an interceptor record.

Appends to the :interceptors in the conector map, or does nothing if interceptor is nil.

interceptor must be an interceptor record, or convertable to an interceptor record.
sourceraw docstring

with-interceptorsclj

(with-interceptors connector-map interceptors)

Appends a sequence of interceptors using with-interceptor.

Appends a sequence of interceptors using [[with-interceptor]].
sourceraw docstring

with-resource-accessclj

(with-resource-access connector-map root-path)

Adds an interceptor exposing access to resources on the classpath system, routed at root-path; this uses [[file]]. The URI / maps to the contents of the classpath with a prefix of root-path.

This should be called just before adding a routing interceptor.

This is an alternative to [[resource-routes]], and should only be used when resource routing would conflict with other routes.

Adds an interceptor exposing access to resources on the classpath system, routed at root-path; this uses
[[file]]. The URI `/` maps to the contents of the classpath with a prefix of `root-path`.

This should be called just before adding a routing interceptor.

This is an alternative to [[resource-routes]], and should only be used when resource routing would conflict
with other routes.
sourceraw docstring

with-routingcljmacro

(with-routing connector-map router-constructor & route-fragments)

A macro for adding a routing interceptor (and an interceptor to decode path parameters) to the connector map. This is generally the last step in building the interceptor chain.

This is a wrapper around the [[routes-from]] macro, which helps with developing at the REPL.

The router-constructor is a function that is passed the expanded routes and returns a routing interceptor. It may also be one of :sawtooth, :map-tree, :prefix-tree, or :linear-search (the four built-in router constructors). :sawtooth is a good default for new applications especially.

The provided route-fragments must extend the [[ExpandableRoutes]] protocol; these will either be [[RoutingFragment]]s (from directly invoking a function such as [[table-routes]]) or a data structure (vector, map, or set) that can be implicitly converted to a RoutingFragment.

At least one route fragment is required.

Evalulates to the connector map with two added interceptors:

  • A routing interceptor
  • A [[path-params-decoder]]
A macro for adding a routing interceptor (and an interceptor to decode
path parameters) to the connector map.
This is generally the last step in building the interceptor chain.

This is a wrapper around the [[routes-from]] macro, which helps with
developing at the REPL.

The router-constructor is a function that is passed the expanded routes and returns
a routing interceptor.  It may also be one of :sawtooth, :map-tree, :prefix-tree,
or :linear-search (the four built-in router constructors). :sawtooth is
a good default for new applications especially.

The provided route-fragments must extend the [[ExpandableRoutes]] protocol; these will
either be [[RoutingFragment]]s (from directly invoking a function such as
[[table-routes]]) or a data structure (vector, map, or set) that can be implicitly
converted to a RoutingFragment.

At least one route fragment is required.

Evalulates to the connector map with two added interceptors:

- A routing interceptor
- A [[path-params-decoder]]
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close