| 1 | #include <kore/kore.h> |
| 2 | #include <kore/http.h> |
| 3 | |
| 4 | int page(struct http_request *); |
| 5 | |
| 6 | int |
| 7 | page(struct http_request *req) |
| 8 | { |
| 9 | const char *custom; |
| 10 | |
| 11 | /* |
| 12 | * We'll lookup if the X-Custom-Header is given in the request. |
| 13 | * If it is we'll set it as a response header as well. |
| 14 | * |
| 15 | * The value returned by http_request_header() should not be freed. |
| 16 | */ |
| 17 | if (http_request_header(req, "x-custom-header", &custom)) |
| 18 | http_response_header(req, "x-custom-header", custom); |
| 19 | |
| 20 | /* Return 200 with "ok\n" to the client. */ |
| 21 | http_response(req, 200, "ok\n", 3); |
| 22 | |
| 23 | return (KORE_RESULT_OK); |
| 24 | } |