ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Context

Description

Per-request mount wiring, runtime capabilities, and the serve handler monad. Dispatch pairs one MountBinding with ServeRuntime and establishes the ambient katip context. The composition root supplies the runtime capabilities.

Synopsis

Request runtime

data ServeRuntime Source #

Serve capabilities assembled at boot. Both HTTP managers must validate TLS certificates.

Constructors

ServeRuntime 

Fields

Packument-serve dependencies

data PackumentDeps Source #

Mount inputs shared by packument and tarball handlers, resolved at boot.

Constructors

PackumentDeps 

Fields

pdPrivateBaseUrl :: PackumentDeps -> Maybe RegistryUrl Source #

The private URL bound to the host gate. Nothing skips the private fetch.

pdPublicBaseUrl :: PackumentDeps -> RegistryUrl Source #

The public upstream base URL. Reads are anonymous, with no client credential.

pdPrivateBase :: PackumentDeps -> Maybe BaseRequest Source #

pdPrivateBaseUrl parsed once per mount, which the private reads build their requests under.

pdPublicBase :: PackumentDeps -> BaseRequest Source #

pdPublicBaseUrl parsed once per mount, which the public reads build their requests under.

pdMirror :: PackumentDeps -> MirrorServePlan Source #

The mirror destination for admitted public artifacts, or no write for a serve-only mount.

pdTarballHostGate :: PackumentDeps -> TarballHostGate Source #

The host gate derived from the mount's upstreams at boot.

tarballHostHonoured :: Origin -> PackumentDeps -> Maybe HostPort -> Maybe HostPort -> Bool Source #

tarballHostAllowed over this mount's inputs. A missing authority refuses, and trusted origins skip only the internal-range block.

Publish-serve dependencies

data PublishDeps Source #

First-party publish inputs. Their presence enables the mount's publish route.

Constructors

PublishDeps 

Fields

The serve action, and the router an adapter supplies

data RouteAction Source #

A route's response contract and an action that answers only through it, so dispatch needs no ecosystem's response sum.

Constructors

RouteAction (ResponseContract response) (ResponseAction response) 

data ResponseAction response Source #

A matched request's action, constrained to its route's response contract.

Constructors

AnswerLocally response

A pure value admitted by the route's response contract.

AnswerRefusal (Maybe HelpMessage -> response)

A refusal the route decided, rendered where the mount's help message is known.

RunPipeline ~response (Request -> (response -> IO ResponseReceived) -> Handler ResponseReceived)

A data-plane handler and its pre-commit fallback, both constrained to the route's response type. The fallback is lazy: only an escape before commit reads it, so a request that commits never builds it.

type MountRouter = Method -> RequestHeaders -> [Text] -> RouteAction Source #

An adapter's routing decision over a method, headers, and the stripped, decoded path segments.

Mount binding

data MountBinding Source #

Ecosystem wiring under a non-empty prefix, so adding an ecosystem never displaces a root mount.

Constructors

MountBinding 

Fields

Per-request context

data RequestCtx Source #

The runtime and the matched MountBinding one request is served through, built once per request.

Constructors

RequestCtx 

Fields

Instances

Instances details
MonadReader RequestCtx Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

The handler monad

data Handler a Source #

Request context over katip's reader-based logging context, shared across concurrent fetches.

Instances

Instances details
MonadIO Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

Methods

liftIO :: IO a -> Handler a #

Applicative Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

Methods

pure :: a -> Handler a #

(<*>) :: Handler (a -> b) -> Handler a -> Handler b #

liftA2 :: (a -> b -> c) -> Handler a -> Handler b -> Handler c #

(*>) :: Handler a -> Handler b -> Handler b #

(<*) :: Handler a -> Handler b -> Handler a #

Functor Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

Methods

fmap :: (a -> b) -> Handler a -> Handler b #

(<$) :: a -> Handler b -> Handler a #

Monad Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

Methods

(>>=) :: Handler a -> (a -> Handler b) -> Handler b #

(>>) :: Handler a -> Handler b -> Handler b #

return :: a -> Handler a #

Katip Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

KatipContext Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

MonadUnliftIO Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

Methods

withRunInIO :: ((forall a. Handler a -> IO a) -> IO b) -> Handler b #

MonadReader RequestCtx Handler Source # 
Instance details

Defined in Ecluse.Core.Server.Context

runHandler :: LogEnv -> SimpleLogPayload -> RequestCtx -> Handler a -> IO a Source #

Run a handler with the application's log stream and initial trace-correlation payload.