Liking cljdoc? Tell your friends :D

Chain Providers

Pedestal uses a chain of interceptors.adoc to process incoming HTTP requests and provide outgoing HTTP responses. However, the underlying code - the interceptors and the interceptor chain that executes them - is more general.

Interceptor chains can be used for a variety of operations, such as:

  • Processing messages from a queue, such as Kafka or JMS

  • Performing a series of transformations on documents as part of a publishing service

  • Processing outgoing requests and incoming responses from a back-end service

A chain provider is responsible for accepting an incoming stimuli (such as an incoming HTTP request) and setting up a context-map.adoc and initial interceptors to process that stimuli. The service map is processed via the api:execute[ns=io.pedestal.interceptor.chain] function.

Part of a chain provider’s responsibility is to identify when a request has been processed; for HTTP requests, this is when a handler or some other interceptor attaches a :response map to the context map.

Pedestal itself only provides a chain provider implementation for incoming HTTP request processing, in the form of the servlet-interceptor.adoc.

Essentially, the chain provider configures the interceptor chain and answers the following questions:

  • When does the chain terminate early (for HTTP, when the :response key is attached)

  • What interceptors execute (some provided by the provider, the rest provided by the application)

  • What happens when execution first goes asynchronous (because an interceptor returns a {core_async} channel)?

Can you improve this documentation? These fine people already did:
Howard Lewis Ship & Howard M. Lewis Ship
Edit on GitHub

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

× close