# HTTP Services ARO provides built-in HTTP server capabilities using a **contract-first** approach. Routes are defined in an OpenAPI specification, and ARO feature sets handle the requests. ## Contract-First HTTP ARO uses OpenAPI contracts to define HTTP routes. The HTTP server automatically starts when a contract file is present in your application directory. The runtime looks for files in this precedence order: `openapi.yaml`, `openapi.yml`, `openapi.json`. **Key Principles:** 1. Routes are defined in your OpenAPI contract, not in ARO code 2. Feature set names must match `operationId` values from the contract 3. No HTTP server without a contract (no OpenAPI file = no server) ## Application Structure ``` MyAPI/ ├── openapi.yaml # Required: Defines all HTTP routes ├── main.aro # Application-Start with Keepalive └── handlers.aro # Feature sets matching operationIds ``` ## Defining Routes (openapi.yaml) ```yaml openapi: 3.0.3 info: title: User API version: 1.0.0 paths: /users: get: operationId: listUsers # Feature set name in ARO responses: '200': description: Success post: operationId: createUser # Feature set name in ARO responses: '201': description: Created /users/{id}: get: operationId: getUser # Feature set name in ARO parameters: - name: id in: path required: true schema: type: string responses: '200': description: Success ``` ## Route Handlers Feature sets must be named after the `operationId` from your OpenAPI contract: ```aro (* Feature set name = operationId from openapi.yaml *) (listUsers: User API) { the from the . an with . } (createUser: User API) { the from the . the with . the into the . a with . } (getUser: User API) { the from the . the from the where id = . an with . } ``` ## Application Entry Point The HTTP server starts automatically. Use `` to keep the application running: ```aro (Application-Start: User API) { "User API starting..." to the . the for the . an for the . } ``` ## Request Data Access ### Path Parameters ```aro the from the . ``` ### Query Parameters ```aro the from the . ``` ### Request Body ```aro the from the . ``` ### Request Headers ```aro the from the . ``` ## Response Status Codes ```aro (* 2xx Success *) an with . (* 200 *) a with . (* 201 *) a for . (* 204 *) (* 4xx Client Errors *) a with . (* 400 *) an for . (* 401 *) a for . (* 403 *) a for . (* 404 *) (* 5xx Server Errors *) an for . (* 500 *) ``` ## HTTP Client For making outgoing HTTP requests, use the `` action: ```aro the from "https://api.example.com/resource". ``` For more details on HTTP client functionality including configuration objects, headers, and POST/PUT requests, see [HTTP Client](Guide-HTTP-Client). ## Next Steps - [File System](Guide-File-System) - File operations and monitoring - [Sockets](Guide-Sockets) - TCP communication - [Events](Guide-Events) - Event-driven patterns