Comments (8)
This is an interesting suggestion. I will have to think about how I want to approach the API for this, as the route regex is compiled when the route is created
from martini.
I'd really appreciate this feature.
from martini.
https://groups.google.com/forum/#!topic/martini-go/AHVTk7wqdRk
from martini.
I think that's already implemented https://github.com/go-martini/martini/blob/master/router.go#L184. Can I close the issue?
from martini.
Yup. Close it out!
from martini.
I started building a Martini app. I'm having an issue with trailing slashes but I don't understand the conclusion of this issue or the referenced code (which indicates "that's already implemented").
Looking at the Google Groups discussion, I want strict slashes (for the reasons clearly outlined in this article).
However, it isn't at all clear to me from this discussion whether that is possible and, if so, how? The bottom line is, how do I put Martini in a "StrictSlash" mode (either globally, which would be fine for me, or on a per route basis)?
Thanks.
from martini.
OK, I figured out a solution. Perhaps this was implied by the previous comments, but it wasn't obvious to me. What I wanted was to have unique handlers for /tasks
and /tasks/
. What I did was to register the patterns as /tasks$
and /tasks/$
, respectively. That seems to have addressed the issue (at least for now).
Is there a better way to achieve the same result?
Thanks.
from martini.
One caveat to my previous solution. It doesn't work with patterns. If I try to register /book/:id$
the regular expression matching the pattern includes the $
which results in a bogus regular expression. A quick workaround was to register the route as /book/(:id)$
because the ()
delimit the pattern and prevent the $
from getting sucked in.
A better solution would be to take the regular expression on this line and change it to :[^$/#?()\.\\]+
since it seems clear there is no use case for having a $
in a pattern. If people think that makes sense, I could submit a pull request for that change. However, I'm not sure what testing protocol is used here (just normal go test
or is there something more extensive somewhere?) and it seems like a pretty sensitive section of the code (since it could definitely break stuff). So a primarily developer might be better to make the change. Just let me know.
from martini.
Related Issues (20)
- Does martini really support html5 Mode serving of static files? HOT 1
- Why HEAD method called on Get Routing?
- Link broken HOT 1
- Handling Gorilla Websockets
- Website hacked? HOT 1
- Wrong link? http://martini.codegangsta.io shows online gambling advertisement only HOT 1
- Use render.Render in ReturnHandler
- unit
- Unit Test
- Add support for promhttp HOT 2
- Hook to log errors if status code > 399 HOT 1
- typecheck arguments on boot-up
- How to include auth middleware that handles roles for logged-in users HOT 1
- cannot set headers HOT 1
- how to break-out of middleware chain using Martini HOT 2
- Problems with # in route matching HOT 1
- Contribution, Arabic translation
- How to become a maintainer?
- is this project dead? HOT 2
- Football
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 martini.