vercel-community / rust

🦀 Rust runtime for ▲ Vercel Serverless Functions
https://rust-runtime.vercel.app
MIT License
816 stars 50 forks source link

Looking for example with an index route and [id].rs #149

Closed abcd-ca closed 3 months ago

abcd-ca commented 3 months ago

In NextJS for example, we can have routes defined with file paths,

/api/event/index.js
/api/event/[id].js

accessed in the url respectively as,

/api/event
/api/event/123

I can't figure out what the index route Rust file should be called. I tried index.rs and mod.rs but in both cases I had to add that to the URL. I want to be able to define index.rs but omit it in the url.

Thank you

dglsparsons commented 3 months ago

Looking at the routing code, I don't believe we special case anything for this pattern.

Would it not work having /api/event.rs and api/event/[id].rs though?

abcd-ca commented 3 months ago

@dglsparsons Yes, that does the trick, thank you.