From b131cb8ea660e0267dbfd0192e6d4b0fa94f05f1 Mon Sep 17 00:00:00 2001 From: floscodes Date: Sat, 20 May 2023 17:38:59 +0200 Subject: [PATCH] update README --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7b4985d..68d4a69 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # zerve + A simple framework for writing web services in zig. * [Create a simple Web App](#create-a-simple-web-app) @@ -112,11 +113,29 @@ fn index(req: zrv.Request) zrv.Response { const user = req.getQuery("user"); // This will return an optional - if (user == null) return Response.write("") else return Response.write(user); + if (user == null) return Response.write("") else return Response.write(user.?); } ``` +### Get value of Request header by key + +You can get the header value of any sent header by the client with the `header`method of `Request`. + +Example: + +```zig +fn index(req: *zrv.Request) zrv.Response { + + // Get value of the 'Content-Type' header + + const h = req.header("Content-Type"); // This will return an optional + + if (h == null) return Response.write("Header not found!") else return Response.write(h.?); + +} +``` + ## Response A Response that is sent ny the server. Every handler function has to return a `Response`.