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

Http4s context routes support in server interpreter #3101

Merged
merged 2 commits into from
Aug 18, 2023

Conversation

mprevel
Copy link
Contributor

@mprevel mprevel commented Aug 9, 2023

Hi,

This PR adds ContextRoutes (so also its type alias AuthedRoutes) support to Http4sServerInterpreter.
It allows to delegate some data extraction to http4s or to integrate with libraries that already provide enriched requests with a context (e.g authenticated user profile).

More information at https://softwaremill.community/t/http4s-authedroutes-support-in-http4sserverinterpreter/263

Regards,

@mprevel mprevel force-pushed the http4s_context_routes branch from d6435de to f0bff06 Compare August 9, 2023 15:32
@kciesielski kciesielski requested a review from adamw August 10, 2023 08:58
@adamw
Copy link
Member

adamw commented Aug 17, 2023

Thanks for the PR :) I'd like to build on that and propose an alternative implementation (see my commit), which uses an extension method to add a "regular" endpoint input, which extract the context from http4s's request. However, it also adds a capability requirement to the endpoint, so it can only be interpreted using .toContextRoutes. I think this is more in-line with how tapir generally works, and allows specifying the server logic using the usual methods, plus interpreting multiple endpoints in a single go. What do you think?

@mprevel
Copy link
Contributor Author

mprevel commented Aug 17, 2023

Thanks, I like your alternative implementation. 👍

@adamw adamw merged commit f149c99 into softwaremill:master Aug 18, 2023
@adamw
Copy link
Member

adamw commented Aug 18, 2023

Great, let's try it then :)

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