Skip to content

Routing

Bruno Dias edited this page May 10, 2026 · 1 revision

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

Why routing matters

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.

Typical responsibilities

A routing system often supports the following responsibilities:

  • mapping paths to handlers
  • distinguishing between GET, POST, PUT, and DELETE
  • extracting path and query parameters
  • applying middleware or feature logic around handlers
  • defining fallback behavior for unmatched routes

Organizing 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.

Route handlers

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

Best practices

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

Related pages

Clone this wiki locally