Skip to content

Add support for custom service contexts - #274

Merged
vlovgr merged 1 commit into
mainfrom
service-custom-contexts
Sep 28, 2026
Merged

vlovgr merged 1 commit into
mainfrom
service-custom-contexts

Conversation

@vlovgr

@vlovgr vlovgr commented Sep 26, 2026

Copy link
Copy Markdown
Member

Instead of always having a fixed ctx: Headers for generated service methods, we define Service.WithContext[F[_], A] with a custom context A. We let Service[F[_]] extends Service.WithContext[F, Headers] to keep source compatibility (but not binary compatibility). Existing Service.fromClient and toRoutes keep their shape, but we now also generate:

def toRoutes[F[_]: Temporal, A](
  serviceImpl: WithContext[F, A], 
  mkCtx: Request[F] => F[A]
): HttpRoutes[F]

def toRoutes[F[_]: Temporal, A](
  serviceImpl: WithContext[F, A], 
  mkCtx: Request[F] => F[A], 
  maxMessageSize: Int
): HttpRoutes[F]

and the following similar overloads for fromClient.

def fromClient[F[_]: Concurrent, A](
  client: Client[F], 
  baseUri: Uri, 
  mkHeaders: A => F[Headers]
): WithContext[F, A]

def fromClient[F[_]: Concurrent, A](
  client: Client[F], 
  baseUri: Uri, 
  mkHeaders: A => F[Headers], 
  maxMessageSize: Int
): WithContext[F, A]

Fixes #144.

@vlovgr
vlovgr merged commit e5f4092 into main Sep 28, 2026
20 checks passed
@vlovgr
vlovgr deleted the service-custom-contexts branch September 28, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow server implementation to access extra attributes

1 participant