Connector Map
Pedestal provides functions to create a connector.
The service map contains general information that any Pedestal connector will need to create a network connector. This is supplemented by a connector-specific configuration map.
Connector Map Keys
An initial connector map can be created by default-connector-map
.
Key | Type | Description |
---|---|---|
:port |
Number |
Port for the network connector to receive connections on |
:host |
String |
Hostname to listen on, defaults to "localhost" |
:router |
Keyword or fn |
Routing constructor to use, default is :sawtooth |
:interceptors |
Vector |
Interceptor to used when processing requests. |
:initial-context |
Map |
Initial context that will be used when executing the interceptor chain |
:join? |
Boolean |
If true (the default is false) then the current thread will block when the connector is started. |
The created Pedestal connector will often prefix the supplied interceptors with ones specific to the connector.
Supplying an :initial-context is a way to provide useful data, functions, or components to all interceptors and handlers. |
Default interceptors
The with-default-interceptors
function is used to add interceptors to the service map for much
common functionality. It is passed the service map and an additional configuration map and will
add interceptors for the following functionality:
-
Request tracing
-
Request logging
-
Allowed origins
-
Session support
-
Cross site request forgery detection
-
Default content type for responses
-
Parsing of query parameters
-
Secure headers (adds a few headers to improve security)
|
Files and Resources
The with-file-access
and with-resource-access
functions add interceptors that will expose
file system or class path resources to the client; this is an alternative to exposing
files and resources via routes.
Routing
The with-routes
macro is used to set the routes for your service.
It is a macro because it sets up a REPL-friendly
workflow (when in development mode).
Creating the Pedestal connector
The service map is passed to a Pedestal connector factory function, along with a map of configuration
specific to the Pedestal connector, and returns a
PedestalConnector
object, which can be started with start!
.
Factory functions:
-
create-connector
(Jetty) -
create-connector
(Http-Kit)
Development Mode
Functions in the
io.pedestal.connector.dev
namespace provide additional support that may be used
when developing and testing locally, but should not be used in production.