Liking cljdoc? Tell your friends :D

immutant.web.middleware

Ring middleware useful with immutant.web

Ring middleware useful with immutant.web
raw docstring

wrap-developmentclj

(wrap-development handler)

Wraps stacktrace and reload middleware with the correct :dirs option set, but will toss an exception if either the passed handler isn't a normal Clojure function or ring/ring-devel isn't available on the classpath

Wraps stacktrace and reload middleware with the correct :dirs
option set, but will toss an exception if either the passed handler
isn't a normal Clojure function or ring/ring-devel isn't available
on the classpath
sourceraw docstring

wrap-sessionclj

(wrap-session handler)
(wrap-session handler options)

Uses the session from either Undertow or, when deployed to an app server cluster such as WildFly or EAP, the servlet's possibly-replicated HttpSession. By default, sessions will timeout after 30 minutes of inactivity.

Supported options:

  • :timeout The number of seconds of inactivity before session expires [1800]
  • :cookie-name The name of the cookie that holds the session key ["JSESSIONID"]

A :timeout value less than or equal to zero indicates the session should never expire.

When running embedded, i.e. not deployed to a WildFly/EAP container, another option is available:

  • :cookie-attrs A map of attributes to associate with the session cookie [nil]

And the following :cookie-attrs keys are supported:

  • :path - the subpath the cookie is valid for
  • :domain - the domain the cookie is valid for
  • :max-age - the maximum age in seconds of the cookie
  • :secure - set to true if the cookie requires HTTPS, prevent HTTP access
  • :http-only - set to true if the cookie is valid for HTTP and HTTPS only (ie. prevent JavaScript access)

Within WildFly/EAP, :cookie-attrs is ignored because a servlet context may only be configured at deployment. This means non-standard cookie configuration must be done in WEB-INF/web.xml.

Uses the session from either Undertow or, when deployed to an app
server cluster such as WildFly or EAP, the servlet's
possibly-replicated HttpSession. By default, sessions will timeout
after 30 minutes of inactivity.

Supported options:

   * :timeout The number of seconds of inactivity before session expires [1800]
   * :cookie-name The name of the cookie that holds the session key ["JSESSIONID"]

A :timeout value less than or equal to zero indicates the session
should never expire.

When running embedded, i.e. not deployed to a WildFly/EAP container,
another option is available:

   * :cookie-attrs A map of attributes to associate with the session cookie [nil]

And the following :cookie-attrs keys are supported:

   * :path      - the subpath the cookie is valid for
   * :domain    - the domain the cookie is valid for
   * :max-age   - the maximum age in seconds of the cookie
   * :secure    - set to true if the cookie requires HTTPS, prevent HTTP access
   * :http-only - set to true if the cookie is valid for HTTP and HTTPS only
                  (ie. prevent JavaScript access)

Within WildFly/EAP, :cookie-attrs is ignored because a servlet
context may only be configured at deployment. This means
non-standard cookie configuration must be done in
`WEB-INF/web.xml`.
sourceraw docstring

wrap-websocketclj

(wrap-websocket handler callbacks)
(wrap-websocket handler key value & key-values)

Middleware to attach websocket callbacks to a Ring handler.

The following callbacks are supported, where channel is an async channel, throwable is a Java exception, and message may be either a String or a byte[]:

  • :on-message (fn [channel message])
  • :on-open (fn [channel])
  • :on-close (fn [channel {:keys [code reason]}])
  • :on-error (fn [channel throwable])

If handler is nil, a 404 status will be returned for any non-websocket request. Also see immutant.web.async/as-channel.

Middleware to attach websocket callbacks to a Ring handler.

The following callbacks are supported, where `channel` is an async
channel, `throwable` is a Java exception, and `message` may be
either a `String` or a `byte[]`:

* :on-message `(fn [channel message])`
* :on-open    `(fn [channel])`
* :on-close   `(fn [channel {:keys [code reason]}])`
* :on-error   `(fn [channel throwable])`

If handler is nil, a 404 status will be returned for any
non-websocket request. Also see [[immutant.web.async/as-channel]].
sourceraw docstring

wrap-write-error-handlingclj

(wrap-write-error-handling handler error-handler)

Sets the :write-error-handler for each request to error-handler, unless it is already set.

See immutant.web/run for more details on :write-error-handler.

Sets the :write-error-handler for each request to error-handler,
unless it is already set.

See [[immutant.web/run]] for more details on :write-error-handler.
sourceraw docstring

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

× close