Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document HandlerAspect in middleware.md #2729

Merged
merged 6 commits into from
Apr 5, 2024

Conversation

SmedbergM
Copy link
Contributor

Middlewares that return values for consumption by handlers (i.e. HandlerAspects) need documenting.

@CLAassistant
Copy link

CLAassistant commented Mar 15, 2024

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

codecov-commenter commented Mar 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.56%. Comparing base (1254d2d) to head (3d97cda).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2729   +/-   ##
=======================================
  Coverage   64.56%   64.56%           
=======================================
  Files         148      148           
  Lines        8649     8649           
  Branches     1573     1573           
=======================================
  Hits         5584     5584           
  Misses       3065     3065           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This can be achieved with the `HandlerAspect[Env, CtxOut]` type, which extends `Middleware[Env]`.
This middleware produces a value of type `CtxOut` on each request, which the routing DSL will accept just like a path component:

```scala
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please try to use the mdoc as much as possible for snippet codes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, though I don't know how much that adds here, since these snippets won't compile as written.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal is to make the code snippets maintainable by ensuring they can be compiled against the source code. So the "crash" modifier isn't helpful in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't use crash but rather fail (the former is for code that compiles but fails at runtime, the latter for code that won't compile in the first place).

In any case, I had to resort to the hack of a mdoc:invisible block to declare some names.

@jdegoes jdegoes merged commit 5fd241f into zio:main Apr 5, 2024
14 checks passed
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.

5 participants