Introduction
KScript.Http turns kscript serve into a server framework. A route file maps HTTP methods and paths to controllers. A controller is an ordinary fn that returns a view, JSON or a response. Middleware runs around controllers, for logging, CORS, sign-in, rate limits or checks of your own.
Pages you already have keep working. kscript serve sends each request to the routes first, and anything no route matches goes on to the site's pages and files.
| Command | What it does |
|---|---|
kscript serve samples/http-app | Serve the sample, then open http://localhost:8080/people. |
kscript routes samples/http-app | Print the route table. |
kscript openapi samples/http-app | Print the OpenAPI document made from the routes. |
samples/http-app is a complete site with web routes, API routes, a controller, views, custom middleware and a kscript.json.