adhocteam / pushup

Pushup is for making modern, page-oriented web apps in Go
https://pushup.adhoc.dev
MIT License
840 stars 30 forks source link

Ergonomics of path parameters #43

Open dvogel opened 1 year ago

dvogel commented 1 year ago

Given the emphasis on file-based routing, I think it would be good to avoid $ for path parameters. It is very easy to forget to escape it in a case like this:

mv app/pages/$thing.up app/pages/nested/

The obvious choice of ^ also needs to be escaped. The example in the README defers to the more conventional /prefix/:param syntax. That could be an option since : does not need to be escaped. One annoyance is that is in bash it does not autocomplete from mv :<TAB>.


Separate from the filename, I think before committing to this approach, it would be worth a research dive into the question of how to handle URLs like /users/:id/profile/ssh_keys/:key_id

The 404 for this turned out to be an error on my part, too focused on getting the $ escaped that I accidentally named my directory $id.up instead of $id.

paulsmith commented 1 year ago

^ is interesting: it doesn't look like I need to escape it if I just type it directly in to my Bash shell as part of a filename, but if I do an ls on the file it is wrapped in quotes.

$ touch ^myfile
$ ls 
'^myfile'

I couldn't find any documentation about whether ^ is a special character to Bash. It doesn't appear in the lists of special chars at least that I could tell from a quick search. Do you know if it is interpreted specially by the shell?

Messing around a bit, I found I liked @ and +, and neither seemed to need any special handling.

I agree that $ is a potential footgun.