Comments (4)
The problem with this approach is it will require type signatures for routes. Since we're using OverloadedStrings
, there would be no way for Haskell to know how to interpret this:
get "/hello"
It requires writing this instead:
get ("/hello" :: Text)
...yuck.
So as I see it there are a few options:
-
Introduce general functions like
fget
,fpost
etc that behave like specified above, and leave the existingget
,post
etc functions alone. Sofget
is toget
asfmap
is tomap
. -
Introduce a new function
getr
that works for regexes only:getr :: Regex -> ActionM () -> ScottyM()
Which I don't like as much because it feels like we don't get as much for crowding the namespace.
If we decide to go with either of those approaches, we'll have to choose a regex library to add as a dependency. I wish Haskell had a standard regex library :P
The final option is to ignore regexes and just support wildcards *
. Thoughts?
from scotty.
Hi Aditya.
I've implemented a Regex routes using a new datatype. Have a look and see if you like it. I've sent a pull request, but it would be good to get someone else to have a look.
from scotty.
See my comments inline. Looks great, I'd like to get this merged in!
from scotty.
Added in commit f5a99eb. Closing.
from scotty.
Related Issues (20)
- Is MonadReader ActionEnv (ActionT m) a good idea? HOT 1
- The name captureParam is a bit strange HOT 1
- doesn't compile against ghc 9.6.3 seems to need a version bump HOT 4
- Not able to rewrite the query string using Network.Wai.Middleware.Rewrite HOT 5
- [RFC] OpenAPI interop
- Expose Cookie via the main interface
- Add doctest
- Variable not in scope: pathParam In examples/basic.hs file HOT 3
- Establish API deprecation and cleanup policy
- SQLite module
- Accept text-2.1 HOT 1
- Update README with Stackage badges
- Undocumented change to the `File` type definition HOT 1
- Dependency upper bounds HOT 1
- Exception information is lost HOT 7
- Update CI to new action
- Add changelog for #374 HOT 1
- warp-3.4 not accepted HOT 2
- Optional validation of header contents
- Don't export ParseRequestBodyOptions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scotty.