The major parts of Pedestal are isolated via Clojure protocols. The protocols are for internal structure and external extension. This reference identifies the most important protocols in Pedestal’s structure and how you might use them in an application.
IntoInterceptor allows pretty much anything to become an interceptor when needed.
Routers use this when building routes: anything that satisfies IntoInterceptor is legal to use in the interceptor vector of a route.
This protocol also comes into play when appending new interceptors to the queue.
Pedestal extends IntoInterceptor onto a variety of Clojure and Java types. See the interceptors reference for details of their behaviors.
ExpandableRoutes can convert all kinds of data structures representing a set of routes into a single canonical format that can be used to construct a routing function. This expansion occurs inside the api:expand-routes[ns=io.pedestal.http.route] function.
Pedestal provides implementations of ExpandableRoutes for several types:
Type | Interpretation |
clojure.lang.APersistentVector | |
clojure.lang.APersistentMap | |
clojure.lang.APersistentSet |
Likewise, each of the underlying routing specification functions (such as api:table-routes[ns=io.pedestal.http.route.definition.table]) returns an ExpandableRoutes.
Since the call to expand-routes comes from application code, it would be rare for an application to need to extend ExpandableRoutes.
The result of expand-routes is a wrapper around a seq of maps that will be passed to the routing contructor function.
A connector encapsulates a network adapter, such as jetty.adoc; a connector is responsible for configuring, starting, and stopping the network adapter. In addition, a connector can be used for testing.
These are specific to using Pedestal with a network connector that implements the Jakarta Servlet API, such as jetty.adoc.
This protocol applies to anything that can be in the :body key of a response-map.adoc. The two functions in the protocol tell Pedestal what content type the body implies, and how to serialize the body to an output stream.
Pedestal extends this protocol to several Java and Clojure types to produce the behavior detailed in response-bodies.adoc.
Applications should not assume any output stream type more specific than java.io.OutputStream.
This protocol is a more specific version of WritableBody. If the value in the :body key of a response-map.adoc satisfies WritableBodyAsync, then Pedestal treats it as a streaming result. See streaming.adoc for full details.
It would be rare for an application to extend this protocol. Most of the time, an application would be better off providing an NIO channel or a {core_async} channel in the response body.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close