Your first Wippy HTTP application — a minimal web API with one endpoint.
GET /hello → {"message": "hello world"}
HTTP request
│
▼
gateway (http.service :8080)
│
▼
api (http.router, prefix: /)
│
▼
hello.endpoint (GET /hello)
│
▼
hello (function.lua) → {"message": "hello world"}
Four entries work together:
gateway— HTTP server listening on port 8080api— Router attached to gateway viameta.serverhello— Lua function that handles requestshello.endpoint— RoutesGET /helloto the function
http-hello-world/
├── wippy.lock
└── src/
├── _index.yaml # 4 entries: server, router, function, endpoint
└── hello.lua # Handler: returns JSON
| Entry | Kind | Purpose |
|---|---|---|
app:gateway |
http.service |
HTTP server on :8080 |
app:api |
http.router |
Route dispatcher (prefix: /) |
app:hello |
function.lua |
Handler function |
app:hello.endpoint |
http.endpoint |
Maps GET /hello to handler |
cd examples/http-hello-world
wippy runTest:
curl http://localhost:8080/helloResponse:
{"message":"hello world"}http.service— declares an HTTP server with an address.auto_start: truestarts it withwippy run.http.router— attaches to a server viameta.server: gateway. Routes requests by path prefix.http.endpoint— maps an HTTP method + path to afunction.luahandler. Links to router viameta.router.function.lua— stateless handler. Useshttp.response()to build the response. No request parsing needed for this simple case.res:set_status()thenres:write_json()— response methods must be called separately (chaining doesn't work becauseset_status()doesn't returnres).