I'm trying to create a website that has multiple community feeds like one for bowling and another for poker like so: localhost:8088/communities/bowling & localhost:8088/communities/poker.
I use actix as my webserver operating under the Rust programming language.
Is there a way where all addresses operating under localhost:8088/communities encounter the same web files so that I can just have one main route?
Then store the additional header like /bowling or /poker so that I can commit to separate requests to the server for the relevant post feeds? Maybe I can save the additional header information in a javascript variable when the web page is called? -Like when I go to /poker, a variable named communityType gets set to poker. How would I do something like that?
Because there's no way anyone is making HTML pages for each of ~100s different communities.
Thanks for the help in advance!
I'm not very familiar with this crate, but based on the docs it looks like you can use
#[get("/route/this/function/will/support")]
to define how a route is handled. Assuming that I wrote it correctly, this should respond with small message telling you which community route you are on when using.You could also expand it to have routes for say
#[get("/communities/{name}/forums")]
or#[get("/communities/{name}/{file}")]
to handle common routes all communities have on a per community basis.Edit:
It sounds like you also need to include
.service(communities_route)
in your main function when initializing theApp
to use#[get(x)]
. You also have better control over how the route is handled if you configure the services directly.Here is one snippet from their hello world example. It looks like it prints the request on the server so long as you visit any route other than
"/index.html"
.I recommend looking through their examples on github. It looks like they have a bunch of concise examples for many different use cases.