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

Selectively applied authorization middleware #263

Open
chrismamo1 opened this issue Feb 21, 2021 · 1 comment
Open

Selectively applied authorization middleware #263

chrismamo1 opened this issue Feb 21, 2021 · 1 comment

Comments

@chrismamo1
Copy link

chrismamo1 commented Feb 21, 2021

I would like for some of my handlers to be behind an authorization middleware, and other to be accessible to the general public (e.g account creation, splash page, etc). From what I gather, there is no idiomatic way to accomplish with with Opium. I don't mind brewing my own solution, I'll have to do the work sooner or later anyway. But am I missing something?

@aantron
Copy link

aantron commented Feb 27, 2021

@chrismamo1 At the moment, I am doing this by wrapping individual handlers with Rock.Middleware.apply. I defined it as @@@, so my handlers that need special middleware look like:

let handler =
    some_middleware @@@
    some_more_middleware @@@
    fun req ->
  (* ... *)

You could also look at Sihl, which allows applying a group of middlewares to a group of routes.

In short, it seems you'll need your own solution to some degree.

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

No branches or pull requests

2 participants