Code Monkey home page Code Monkey logo

Comments (8)

codegangsta avatar codegangsta commented on August 18, 2024

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.

icholy avatar icholy commented on August 18, 2024

I'd really appreciate this feature.

from martini.

icholy avatar icholy commented on August 18, 2024

https://groups.google.com/forum/#!topic/martini-go/AHVTk7wqdRk

from martini.

erizocosmico avatar erizocosmico commented on August 18, 2024

I think that's already implemented https://github.com/go-martini/martini/blob/master/router.go#L184. Can I close the issue?

from martini.

codegangsta avatar codegangsta commented on August 18, 2024

Yup. Close it out!

from martini.

xogeny avatar xogeny commented on August 18, 2024

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.

xogeny avatar xogeny commented on August 18, 2024

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.

xogeny avatar xogeny commented on August 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.