softwaremill / softwaremill/tapir
Does ZTapir endpoint execute code within a scope?
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.5k
- Forks
- 468
- Avg merge
- 5h 37m
- Merged PRs (30d)
- 34
Description
Looking at the function signatures for:
def zServerSecurityLogic[R, U](
f: SECURITY_INPUT => ZIO[R, ERROR_OUTPUT, U]
): ZPartialServerEndpoint[R, SECURITY_INPUT, U, INPUT, ERROR_OUTPUT, OUTPUT, C] =
ZPartialServerEndpoint(e, f)
def serverLogic[R0](logic: PRINCIPAL => INPUT => ZIO[R0, ERROR_OUTPUT, OUTPUT]): ZServerEndpoint[R with R0, C] =
ServerEndpoint(
endpoint,
_ => securityLogic(_: SECURITY_INPUT).either.resurrect,
_ => (u: PRINCIPAL) => (i: INPUT) => logic(u)(i).either.resurrect
)
Within zServerSecurityLogic I would like to use ZIO.logAnnotateScoped(_, _) to add log context from within the JWT that will be there for all requests. If this is possible, it would be super ideal to add this here, as all endpoints are already calling a shared function that decodes the JWT.
If things are already executed within a scope, I believe the correct signatures would be: (?)
f: SECURITY_INPUT => ZIO[R & Scope, ERROR_OUTPUT, U]
logic: PRINCIPAL => INPUT => ZIO[R0 & Scope, ERROR_OUTPUT, OUTPUT]
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the zServerSecurityLogic and serverLogic signatures shown in the issue, then trace how ZTapir invokes the shared JWT security logic and endpoint logic. Check whether ZIO.logAnnotateScoped can provide request-wide context there; done means clearly determining the scope behavior and documenting or proposing the required signature changes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100