| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
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
- data ServeRuntime = ServeRuntime {}
- data PackumentDeps = PackumentDeps {
- pdUpstreams :: MountUpstreams
- pdFirstParty :: PackageName -> Bool
- pdMountBaseUrl :: Text
- pdRules :: [PreparedRule]
- pdAdditionalBlockedRanges :: [IPRange]
- pdLimits :: Limits
- pdInboundToken :: Maybe Secret
- pdNow :: IO UTCTime
- pdAdvisoryEtag :: IO (Maybe DbEtag)
- pdNoteAdmission :: AdmissionIdentity -> IO Bool
- pdHelp :: Maybe HelpMessage
- pdMinIntegrity :: MinIntegrity
- pdMinTrustedIntegrity :: MinTrustedIntegrity
- pdMetadata :: AdapterMetadata
- pdArtifact :: AdapterArtifact
- pdEgressUrl :: Text -> Either Text RegistryUrl
- pdPrivateBaseUrl :: PackumentDeps -> Maybe RegistryUrl
- pdPublicBaseUrl :: PackumentDeps -> RegistryUrl
- pdMirror :: PackumentDeps -> MirrorServePlan
- pdTarballHostGate :: PackumentDeps -> TarballHostGate
- tarballHostHonoured :: Origin -> PackumentDeps -> Maybe HostPort -> Maybe HostPort -> Bool
- data PublishDeps = PublishDeps {}
- data RouteAction = RouteAction (ResponseContract response) (ResponseAction response)
- data ResponseAction response
- = AnswerLocally response
- | AnswerRefusal (Maybe HelpMessage -> response)
- | RunPipeline response (Request -> (response -> IO ResponseReceived) -> Handler ResponseReceived)
- type MountRouter = Method -> RequestHeaders -> [Text] -> RouteAction
- data MountBinding = MountBinding {}
- data RequestCtx = RequestCtx {}
- data Handler a
- runHandler :: LogEnv -> SimpleLogPayload -> RequestCtx -> Handler a -> IO a
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.
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 #
Apply tarballHostAllowed with this mount's inputs for both serving and mirror re-evaluation.
A missing authority refuses. Trusted origins bypass 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 matched route's response contract paired with an action that produces only that contract's response type. Dispatch renders the action without knowing an 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, so a route table carries no configuration of its own. |
| 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. |
type MountRouter = Method -> RequestHeaders -> [Text] -> RouteAction Source #
An ecosystem's whole routing decision over a mount-relative request, from its adapter. The method and the headers are part of the mapping, and segments arrive stripped and decoded.
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 context one request is served through: the request runtime paired with the MountBinding
the request matched. Dispatch builds it once per request, and Handler reads it through its reader.
Constructors
| RequestCtx | |
Fields
| |
Instances
| MonadReader RequestCtx Handler Source # | |
Defined in Ecluse.Core.Server.Context Methods ask :: Handler RequestCtx # local :: (RequestCtx -> RequestCtx) -> Handler a -> Handler a # reader :: (RequestCtx -> a) -> Handler a # | |
The handler monad
Request context over katip's reader-based logging context, shared across concurrent fetches.
Instances
| MonadIO Handler Source # | |
Defined in Ecluse.Core.Server.Context | |
| Applicative Handler Source # | |
| Functor Handler Source # | |
| Monad Handler Source # | |
| Katip Handler Source # | |
| KatipContext Handler Source # | |
Defined in Ecluse.Core.Server.Context Methods getKatipContext :: Handler LogContexts # localKatipContext :: (LogContexts -> LogContexts) -> Handler a -> Handler a # getKatipNamespace :: Handler Namespace # localKatipNamespace :: (Namespace -> Namespace) -> Handler a -> Handler a # | |
| MonadUnliftIO Handler Source # | |
Defined in Ecluse.Core.Server.Context | |
| MonadReader RequestCtx Handler Source # | |
Defined in Ecluse.Core.Server.Context Methods ask :: Handler RequestCtx # local :: (RequestCtx -> RequestCtx) -> Handler a -> Handler a # reader :: (RequestCtx -> a) -> Handler a # | |
runHandler :: LogEnv -> SimpleLogPayload -> RequestCtx -> Handler a -> IO a Source #
Run a handler with the application's log stream and initial trace-correlation payload.