-
Notifications
You must be signed in to change notification settings - Fork 4
Support middleware #11
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
base: main
Are you sure you want to change the base?
Conversation
|
@TristanCacqueray I'm having a hard finding an example of "usual" Servant setup to showcase how integrating with |
|
@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? |
|
@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 For instance, this function runHoogle is used with 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 |
|
@TristanCacqueray do you see what I'm talking about? |
|
@Kleidukos ok, so what would be the use case to use natural transform when servant-effectful already provides runWarpServerSettingsContext which takes care of it? |
|
@TristanCacqueray I'm just having a hard time wrapping my mind around the new way to pass the |
|
@TristanCacqueray Just so we are clear, how would you deal with such a thing? https://github.com/flora-pm/flora-server/blob/development/src/web/FloraWeb/Server.hs#L198-L202 |
|
Ha I see, well we actually use some of the effects before serving the API (e.g. to initialize the db), so we have a bunch of E.runEffect before getting to servant-effectful. Here is how that looks in monocle: https://github.com/change-metrics/monocle/blob/8ffa58d7cc93a16a1c1e530b08de6321c29e2f16/src/Monocle/Main.hs#L180-L202 Though we haven't review this implem since the switch to effectful, so perhaps we are doing some wrong, but I think that's what servant-effectful should provide, just the |
|
@alpmestan if you have any insights I'm all ears. :) |
No description provided.