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

Support middleware #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Support middleware #11

wants to merge 1 commit into from

Conversation

Kleidukos
Copy link
Owner

No description provided.

@Kleidukos
Copy link
Owner Author

@TristanCacqueray I'm having a hard finding an example of "usual" Servant setup to showcase how integrating with servant-effectful would look like. I'm blocked on the place that the natural transform would take. Do you have any idea how to showcase "this is what this usually looks like and this is what it will look like"?

@TristanCacqueray
Copy link
Contributor

@Kleidukos I'm not entirely sure what you mean by natural transform, but I would show a named route api implemented with a reader and logger effects. Then we could demonstrate how to serve it along with a basic health-check middleware?

@Kleidukos
Copy link
Owner Author

Kleidukos commented Dec 20, 2024

@TristanCacqueray "natural transform" or "nt" is the term used by Servant to talk about the operation that turns your domain monad (custom reader, etc) back to a Handler monad. See https://docs.servant.dev/en/stable/cookbook/using-custom-monad/UsingCustomMonad.html for instance.

For instance, this function runHoogle is used with genericServeTWithContext (https://git.mangoiv.com/mangoiv/modern-hoogle/src/branch/main/src/Hoogle/Modern.hs#L25-L28)

It's roughly the function where you execute your effects: https://github.com/flora-pm/flora-server/blob/development/src/web/FloraWeb/Server.hs#L207-L228 that serveTWithContext accepts

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.

2 participants