Routing for web templates
BanjoFox opened this issue · 8 comments
Unfortunately I have not had enough spoons to fully understand how to route from Rocket to the full set of templates. So I figured I would post this as an issue. Plus it would be a good "beginner" issue for the Rust Community folks
- Route to template files
- Get tempaltes to "populate" with appropriate values (like PHP include(), as well as files in /lang
Pretty sure that the current routes in /src/aardwolf/routes/app.rs
just need to be updated so that they show up on the root of the webserver and not in /web or /auth.
Also need to find out if every file in /templates
needs to be listed or if there is a way to pull dynamically.
@jvalleroy - Provided a working solution!
I would like others to have a look at it before merging into master because I do not know the original intent for putting them behind /auth and /web >.>
It was really just emulating mastodon's API. /web was always a little pointless. namespacing routes under /auth might be nice if we could apply rules to a whole prefix, but I don't think rocket actually let's you do that, so I'm sure it's fine to remove the prefix
Thanks for explaining. I probably should have asked a million years ago x.X.
As for /auth prefixes I can ask in the Rocket IRC. Sergio hangs out there a lot.
Otherwise maybe @asonix knows?
@pwoolcoc -- Here is the conversation I had over in the Rocket chat room
regarding Rocket/namespaces... does this make sense?
banjofox (hopefully)
quick question: can you apply rules to a whole prefix?
Sergio (IRC)
Rules?
A prefix in a URL?
banjofox
yeah sorry... We're debating wether or not to use an /auth namespace,
Sergio (IRC)
Oh
You can, with fairings
But I'd recommend using request guards instead
banjofox
rather... the full statement from the discussion is:
namespacing routes under /auth might be nice if we could apply rules to a whole prefix
yeah I mean request guards are a good option, and it may make logical sense to have authy things all in the same module. Whether that means they all have a prefix isn't a huge deal.
As far as Fairings, we could totally have a fairing that checks if the URL is prefixed with 'auth' and then performs some action, but honestly Sergio is right thar Request Guards would make more sense.
and sorry I didn't respond sooner, I must have missed this when you tagged me
I think we have this resolved.