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

Reimplement ScottyT in terms of ReaderT #340

Closed
ocramz opened this issue Oct 15, 2023 · 5 comments
Closed

Reimplement ScottyT in terms of ReaderT #340

ocramz opened this issue Oct 15, 2023 · 5 comments

Comments

@ocramz
Copy link
Collaborator

ocramz commented Oct 15, 2023

This would give us local, allowing to apply specific middlewares (e.g. authentication) only on given sets of routes (See #187 ).

Also it would let us unify the exception handling mechanism.

It's only a breaking change if we put the reader variable inside a TVar and some modifying functions gain a MonadIO constraint.

We can use the predicates defined here to inspect HTTP status codes and act accordingly (i.e. throw an exception or not): https://hackage.haskell.org/package/http-types-0.12.3/docs/Network-HTTP-Types-Status.html#v:statusIsInformational


Screenshot 2023-10-15 at 13 39 35
It was ReaderT all along?
Always has been.
@ocramz
Copy link
Collaborator Author

ocramz commented Oct 15, 2023

@fumieval what do you think?

@fumieval
Copy link
Collaborator

ScottyT has nothing to with exceptions because it should never fail, as its sole purpose is to build a WAI application. For this purpose I think State-like monad is a better fit

@ocramz
Copy link
Collaborator Author

ocramz commented Oct 15, 2023 via email

@fumieval
Copy link
Collaborator

If the route definition contains a mistake (e.g. get "/foo" defined twice), perhaps it should throw an error. It should not be caught anyway

@ocramz
Copy link
Collaborator Author

ocramz commented Oct 28, 2023

ok, closing this !

@ocramz ocramz closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants