Coder Social home page Coder Social logo

Order of routes affects pretty URLs about volt HOT 9 CLOSED

voltrb avatar voltrb commented on June 20, 2024
Order of routes affects pretty URLs

from volt.

Comments (9)

dfyx avatar dfyx commented on June 20, 2024

I think this is by design. Rails does basically the same.

from volt.

jaimeiniesta avatar jaimeiniesta commented on June 20, 2024

I don't think so, I understand that by design, the order of the routes is taken into account in the sense that the first match will be used (like Rails), but this is not the case here.

from volt.

ryanstout avatar ryanstout commented on June 20, 2024

@jaimeiniesta So this API might need a little more thought to make it intuitive. At the moment its by design, but your right, its not the most intuitive. Right now it matches top to bottom when going from params to a url. (and vice versa) get '/' matches anything, so it should be at the bottom.

from volt.

ryanstout avatar ryanstout commented on June 20, 2024

I'll leave this one open if anyone wants to discuss their thoughts on the routes. One of my goals with Volt is to have a simple routing system. Not needing to handle different http verbs allows us to simplify things. (Expect extra methods for building REST API's for the backend) I think the idea of routes just mapping params to urls and vice versa could make it easy to learn, but powerful enough to use day to day.

from volt.

jaimeiniesta avatar jaimeiniesta commented on June 20, 2024

Thanks for the explanation, in my opinion the best place for the root path is at the bottom, but I was surprised by this behavior.

Volt does not need to behave like Rails, but in Rails, you can have the root route on the top of the routes file and everything will still work as if it was at the bottom.

What I don't get is, why is it that get '/' matches anything? In my opinion it should not match anything except exactly / , I don't see any wildcard or optional parameter there.

I must surely be missing something about how routes are matched in Volt, but I can't find it in the docs.

from volt.

ryanstout avatar ryanstout commented on June 20, 2024

So front-end routing is a different thing than backend routing because you need to go from both url to params and params to url. So you can think of everything after the url string as constraints for matching.

get '/' might be better written as get '/', {}

Something like ```get '/about', {_controller: 'about'}, only matches when the params._controller == 'about'

get '/' matches any params. Maybe I should just make a root helper that just inserts its-self last.

Let me know if that makes since. Its simple, but maybe not intuitive enough. At this point all of these api's are open to change :-)

from volt.

jaimeiniesta avatar jaimeiniesta commented on June 20, 2024

Ah, alright, thanks a lot for your explanation!

get '/' might be better written as get '/', {}

That was the point that I was missing :)

from volt.

ryanstout avatar ryanstout commented on June 20, 2024

Cool, thats a good idea. I'll add that.

On Sun, Sep 21, 2014 at 4:39 PM, Jaime Iniesta [email protected]
wrote:

Ah, alright, thanks a lot for your explanation!

get '/' might be better written as get '/', {}

That was the point that I was missing :)


Reply to this email directly or view it on GitHub
#43 (comment).

from volt.

ryanstout avatar ryanstout commented on June 20, 2024

I added some more stuff to the readme and generated routes.rb files. Hopefully that helps newcomers.

from volt.

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.