-
Notifications
You must be signed in to change notification settings - Fork 0
Routing
Routing is responsible for connecting incoming web requests to the code that handles them.
In io.github.cl-sdk.wst, routing typically defines:
- which URLs are available
- which HTTP methods they respond to
- which handler should process a request
- how route parameters are extracted and passed along
A clear routing layer helps keep a web application organized. Instead of scattering request logic throughout the codebase, routes provide a central way to describe how the application responds to HTTP requests.
A routing system often supports the following responsibilities:
- mapping paths to handlers
- distinguishing between
GET,POST,PUT, andDELETE - extracting path and query parameters
- applying middleware or feature logic around handlers
- defining fallback behavior for unmatched routes
As an application grows, routes should usually be grouped by area of responsibility. For example:
- public pages
- authentication endpoints
- administrative routes
- API endpoints
This makes the application easier to maintain and allows related behavior to stay close together.
A route handler is the function or callable unit that processes a request and returns a response.
Depending on the design of the application, a handler may:
- render HTML
- return structured data
- redirect the client
- update session state
- invoke application services or domain logic
When defining routes:
- keep handlers focused on request/response concerns
- move business logic into separate functions or services
- use predictable URL structures
- group related routes together
- document non-obvious route behavior
- Introduction
- [Circuit breaker](Features/Circuit breaker)
- Session