Namespace which ties all the pedestal components together in a sensible default way to make a full blown application.
Namespace which ties all the pedestal components together in a sensible default way to make a full blown application.
(create-provider service-map)
Creates the base Interceptor Chain provider, connecting a backend to the interceptor chain.
Creates the base Interceptor Chain provider, connecting a backend to the interceptor chain.
(create-server service-map)
(create-server service-map init-fn)
Given a service map, creates an returns an initialized service map which is
ready to be started via io.pedestal.http/start
. If init-fn, a zero
arg function, is provided, it is invoked first.
Notes:
io.pedestal.http/start-fn
and io.pedestal.http/stop-fn
keys whose values are zero arg functions which
are used to start/stop the http service, respectively.:io.pedestal.http/chain-provider
is present,
it is used to create the server, otherwise a servlet provider will be used.
In this case, the type of servlet container created is determined by the
:io.pedestal.http/type
option.io.pedestal.http/service-fn
key which is useful for testing the service
without starting it.Given a service map, creates an returns an initialized service map which is ready to be started via `io.pedestal.http/start`. If init-fn, a zero arg function, is provided, it is invoked first. Notes: - The returned, initialized service map contains the `io.pedestal.http/start-fn` and `io.pedestal.http/stop-fn` keys whose values are zero arg functions which are used to start/stop the http service, respectively. - If the service map option `:io.pedestal.http/chain-provider` is present, it is used to create the server, otherwise a servlet provider will be used. In this case, the type of servlet container created is determined by the `:io.pedestal.http/type` option. - For servlet containers, the resulting service-map will contain the `io.pedestal.http/service-fn` key which is useful for testing the service without starting it.
(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:
Note: Additional options are passed to default-interceptors if :interceptors is not set.
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 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:
nil
to disable.nil
to disable.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. `nil` to disable. * :request-logger: Interceptor to log requests entering the interceptor chain. Default is the log-request interceptor. `nil` to disable. * :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 :download-options-settings :cross-domain-policies-settings :content-security-policy-settings] If nil, this interceptor is not added. Default is the default secure-headers settings * :path-params-decoder: An Interceptor to decode path params. Default is URL Decoding via `io.pedestal.http.route/path-params-decoder. If nil, this interceptor is not added.
(edn-response obj)
Return a Ring response that will print the given obj
to the HTTP output stream in EDN format.
Return a Ring response that will print the given `obj` to the HTTP output stream in EDN format.
Set the Content-Type header to "text/html" if the body is a string and a type has not been set.
Set the Content-Type header to "text/html" if the body is a string and a type has not been set.
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.
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 obj)
Print object as JSON to out
Print object as JSON to *out*
(json-response obj)
Return a Ring response that will print the given obj
to the HTTP output stream in JSON format.
Return a Ring response that will print the given `obj` to the HTTP output stream in JSON format.
Log the request's method and uri.
Log the request's method and uri.
An interceptor that returns a 404 when routing failed to resolve a route.
An interceptor that returns a 404 when routing failed to resolve a route.
(response? resp)
A valid response is any map that includes an integer :status value.
A valid response is any map that includes an integer :status value.
(start service-map)
Given service-map, an initialized service map returned by create-server
,
invokes the zero-arg function assoc'd to the service map via :io.pedestal.http/start-fn.
Returns service-map
on success.
Given service-map, an initialized service map returned by `create-server`, invokes the zero-arg function assoc'd to the service map via `:io.pedestal.http/start-fn.` Returns `service-map` on success.
(stop service-map)
Given service-map, an initialized service map returned by create-server
,
invokes the zero-arg function assoc'd to the service map via :io.pedestal.http/stop-fn.
Returns service-map
on success.
Given service-map, an initialized service map returned by `create-server`, invokes the zero-arg function assoc'd to the service map via `:io.pedestal.http/stop-fn.` Returns `service-map` on success.
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.
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-body-interceptor iname default-content-type transit-format)
(transit-body-interceptor iname
default-content-type
transit-format
transit-opts)
Returns an interceptor which sets the Content-Type header to the appropriate value depending on the transit format. Converts the body to the specified Transit format if the body is a collection and a type has not been set. Optionally accepts transit-opts which are handed to trasit/writer and may contain custom write handlers.
Expects the following arguments:
iname - namespaced keyword for the interceptor name default-content-type - content-type string to set in the response transit-format - either :json or :msgpack transit-options - optional. map of options for transit/writer
Returns an interceptor which sets the Content-Type header to the appropriate value depending on the transit format. Converts the body to the specified Transit format if the body is a collection and a type has not been set. Optionally accepts transit-opts which are handed to trasit/writer and may contain custom write handlers. Expects the following arguments: iname - namespaced keyword for the interceptor name default-content-type - content-type string to set in the response transit-format - either :json or :msgpack transit-options - optional. map of options for transit/writer
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.
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.
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.
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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close