kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 8d67ee4c5250b1ef904294218c521434a07ad041
parent 088d877715f591c98e469aeaa0402c912dfa2df6
Author: Joris Vink <joris@coders.se>
Date:   Wed, 29 May 2013 14:42:40 +0200

add dynamic handler example to our base module

Diffstat:
example.conf | 5+++--
example/Makefile | 2+-
example/src/example.c | 22++++++++++++++++++----
3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/example.conf b/example.conf @@ -9,5 +9,6 @@ load example/example.module # Declare page handlers below. # handler path module_callback domain 10.211.55.3 -static /css/style.css betrippin_serve_style_css -static / betrippin_serve_index +static /css/style.css serve_style_css +static / serve_index +dynamic ^/[a-z0-9_]*$ serve_profile diff --git a/example/Makefile b/example/Makefile @@ -5,7 +5,7 @@ CC=gcc BIN=example.module -HTML= html/index.html +HTML= html/index.html html/profile.html H_SRCS= $(HTML:.html=.c) CSS= css/style.css diff --git a/example/src/example.c b/example/src/example.c @@ -31,6 +31,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <regex.h> #include <unistd.h> #include <zlib.h> @@ -40,11 +41,12 @@ #include "static.h" -int betrippin_serve_style_css(struct http_request *); -int betrippin_serve_index(struct http_request *); +int serve_style_css(struct http_request *); +int serve_index(struct http_request *); +int serve_profile(struct http_request *); int -betrippin_serve_style_css(struct http_request *req) +serve_style_css(struct http_request *req) { int ret; char *date; @@ -74,7 +76,7 @@ betrippin_serve_style_css(struct http_request *req) } int -betrippin_serve_index(struct http_request *req) +serve_index(struct http_request *req) { int ret; @@ -84,3 +86,15 @@ betrippin_serve_index(struct http_request *req) return (ret); } + +int +serve_profile(struct http_request *req) +{ + int ret; + + http_response_header_add(req, "content-type", "text/html"); + ret = http_response(req, 200, static_html_profile, + static_len_html_profile); + + return (ret); +}