3 Request-Response Cycle
Every interaction on the web, from loading a page to submitting a form, follows the same fundamental pattern: a client sends a request, and a server returns a response.
This exchange, repeated continuously, is the foundation of all web applications, including those built with Ambiorix.
3.1 Client
The cycle begins with the client, which initiates communication by sending a request.
- A client is usually a web browser or any application that wants to interact with your server.
- The request is a message detailing what the client wants eg. a specific web page, some data, or the result of an action.
3.2 Server
The server receives the request from the client, processes it, and prepares a response.
- When you build an Ambiorix application, you are creating a web server. This is the server participating in the cycle.
- A response is whatever the server sends back: an HTML page, JSON data, or a simple confirmation.
3.3 Ambiorix
Ambiorix exposes this cycle directly. Every handler receives the request and response objects because those are the two halves of the ineraction.
reqcontains all the information about the incoming request.resprovides the methods you use to send a response back to the client.
3.4 Browsers
Most interactions you trigger in a browser start with a GET request. This is the default HTTP method for common browser actions.
- Visiting a web page issues a
GETrequest to the server. - An HTML form uses
GETunless you explicitly set another method (such asPOST). - Clicking an anchor tag (
<a>) sends aGETrequest to the URL in itshref.
You can change this behaviour by adding attributes (for example, method = "post" on a form) or by using JavaScript to send requests programmatically.
This also explains what you see when you start an Ambiorix application and open the home page (/) in your browser: the server logs the incoming GET request.
✔ 01-12-2025 11:19:02 Listening on http://0.0.0.0:8000
ℹ 01-12-2025 11:19:05 GET on /Understanding this default behaviour helps make sense of why Ambiorix logs the requests it does, and why certain handlers fire when you navigate or click through the interface.