cloud.Api catch-all route handler
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 215
- Avg merge
- 2h 9m
- Merged PRs (30d)
- 27
Description
Feature Spec
A preflight API for running inflight code that should run on all uncaught routes of a cloud.Api:
bring cloud;
let api = new cloud.Api();
api.get("/users/*", inflight (req) => { /* ... */ });
api.get("*", inflight (req) => { /* ... */ });
Since req: cloud.ApiRequest includes path as a field, the inflight function can perform custom logic based on the actual route the user passed.
Related to https://github.com/winglang/wing/pull/3973, https://github.com/winglang/wing/issues/1848
Use Cases
Specifying custom responses for when a request doesn't match any of the other routes you've specified on your cloud.Api.
This kind of capability is available in other frameworks like Express.js using the "*" syntax (see examples here) and SST using the "{proxy+}" path variable (docs).
Implementation Notes
No response
Component
SDK
Community Notes
- Please vote by adding a 👍 reaction to the issue to help us prioritize.
- If you are interested to work on this issue, please leave a comment.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the cloud.Api SDK entry point and inspect how routes are registered and how unmatched requests are handled. The change is complete when an uncaught route can invoke the catch-all handler and the handler can use req.path to choose a response; check the existing API tests if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100