Web and API

Norscode is very usable for practical web work when handlers, validation and response formatting stay clear. A route handler should answer a small set of questions: is the request allowed, is the input valid, what domain action should run and what response shape should be returned?

Keep handlers focused

Handlers are most maintainable when they parse input, delegate business logic and return HTTP or JSON responses without hiding too much unrelated work inside the route itself.

funksjon hjem_handler(method: tekst, path: tekst, query: tekst, body: tekst) -> tekst {
    returner http_respons_tekst(200, "text/html; charset=utf-8", "<h1>Hei</h1>")
}

Validation and response discipline

Consistent response types, clear error handling and strong validation make web services easier to test and easier to connect to clients. The value is not only correctness. It is also clarity in production.

Useful follow-up chapters are API contracts, security and modules.