io.pedestal.http
Namespace which ties all the pedestal components together in a
sensible default way to make a full blown application.
create-provider
(create-provider service-map)
Creates the base Interceptor Chain provider, connecting a backend to the interceptor
chain.
create-server
(create-server service-map)
(create-server service-map init-fn)
create-servlet
(create-servlet service-map)
Creates a servlet given an options map with keyword keys prefixed by namespace e.g.
:io.pedestal.http/interceptors or ::bootstrap/interceptors if the namespace is aliased to bootstrap.
Options:
* :io.pedestal.http/interceptors: A vector of interceptors that defines a service.
Note: Additional options are passed to default-interceptors if :interceptors is not set.
default-interceptors
(default-interceptors service-map)
Builds interceptors given an options map with keyword keys prefixed by namespace e.g.
:io.pedestal.http/routes or ::bootstrap/routes if the namespace is aliased to bootstrap.
Note:
No additional interceptors are added if :interceptors key is set.
Options:
* :routes: Something that satisfies the io.pedestal.http.route/ExpandableRoutes protocol
a function that returns routes when called, or a seq of route maps that defines a service's routes.
If passing in a seq of route maps, it's recommended to use io.pedestal.http.route/expand-routes.
* :router: The router implementation to to use. Can be :linear-search, :map-tree
:prefix-tree, or a custom Router constructor function. Defaults to :map-tree, which fallsback on :prefix-tree
* :file-path: File path used as root by the middlewares/file interceptor. If nil, this interceptor
is not added. Default is nil.
* :resource-path: File path used as root by the middlewares/resource interceptor. If nil, this interceptor
is not added. Default is nil.
* :method-param-name: Query string parameter used to set the current HTTP verb. Default is _method.
* :allowed-origins: Determines what origins are allowed for the cors/allow-origin interceptor. If
nil, this interceptor is not added. Default is nil.
* :not-found-interceptor: Interceptor to use when returning a not found response. Default is
the not-found interceptor.
* :mime-types: Mime-types map used by the middlewares/content-type interceptor. Default is {}.
* :enable-session: A settings map to include the session middleware interceptor. If nil, this interceptor
is not added. Default is nil.
* :enable-csrf: A settings map to include the csrf-protection interceptor. This implies
sessions are enabled. If nil, this interceptor is not added. Default is nil.
* :secure-headers: A settings map for various secure headers.
Keys are: [:hsts-settings :frame-options-settings :content-type-settings :xss-protection-settings]
If nil, this interceptor is not added. Default is the default secure-headers settings
dev-interceptors
(dev-interceptors service-map)
edn-response
(edn-response obj)
Return a Ring response that will print the given `obj` to the HTTP output stream in EDN format.
html-body
Set the Content-Type header to "text/html" if the body is a string and a
type has not been set.
interceptor-chain-provider
(interceptor-chain-provider service-map)
json-body
Set the Content-Type header to "application/json" and convert the body to
JSON if the body is a collection and a type has not been set.
json-print
(json-print obj)
Print object as JSON to *out*
json-response
(json-response obj)
Return a Ring response that will print the given `obj` to the HTTP output stream in JSON format.
log-request
Log the request's method and uri.
not-found
An interceptor that returns a 404 when routing failed to resolve a route.
response?
(response? resp)
A valid response is any map that includes an integer :status
value.
server
(server service-map)
service-fn
(service-fn {interceptors :io.pedestal.http/interceptors, :as service-map})
servlet
(servlet {service-fn :io.pedestal.http/service-fn, :as service-map})
servlet-destroy
(servlet-destroy service)
servlet-init
(servlet-init service config)
servlet-service
(servlet-service service servlet-req servlet-resp)
transit-body
Same as `transit-json-body` --
Set the Content-Type header to "application/transit+json" and convert the body to
transit+json if the body is a collection and a type has not been set.
transit-json-body
Set the Content-Type header to "application/transit+json" and convert the body to
transit+json if the body is a collection and a type has not been set.
transit-msgpack-body
Set the Content-Type header to "application/transit+msgpack" and convert the body to
transit+msgpack if the body is a collection and a type has not been set.