update README
This commit is contained in:
parent
884b88c931
commit
b131cb8ea6
1 changed files with 20 additions and 1 deletions
21
README.md
21
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`.
|
||||
|
|
Loading…
Reference in a new issue