Beispiel #1
0
tofu_rep_t *handler(tofu_req_t *req, void *argp) {
	tofu_rep_t *rep = tofu_rep_init();

	tofu_status(rep, 418);

	return rep;
}
Beispiel #2
0
tofu_rep_t *status_simple(tofu_req_t *req, void *argp) {
	tofu_rep_t *rep = tofu_rep_init();

	tofu_status(rep, 418);

	return rep;
}
Beispiel #3
0
tofu_rep_t *hello(tofu_req_t *req) {
	tofu_rep_t *rep = tofu_rep_init();

	tofu_head(rep, "Content-Type", "text/html");
	tofu_write(rep, "Hello World!");

	return rep;
}
Beispiel #4
0
tofu_rep_t *error_404(tofu_req_t *req) {
	tofu_rep_t *rep = tofu_rep_init();

	tofu_head(rep, "Content-Type", "text/html");
	tofu_write(rep, "Error 404!");

	return rep;
}
Beispiel #5
0
tofu_rep_t *error_418(tofu_req_t *req) {
	tofu_rep_t *rep = tofu_rep_init();

	tofu_head(rep, "Content-Type", "text/html");
	tofu_write(rep, "Just a teapot!");

	return rep;
}
Beispiel #6
0
tofu_rep_t *handler_500(tofu_req_t *req) {
	tofu_rep_t *rep = tofu_rep_init();

	tofu_head(rep, "Content-Type", "text/html");
	tofu_write(rep, "<!DOCTYPE html>\n<head><title>500</title></head>\n");
	tofu_write(rep, "<body>Error!!!</body>\n");

	return rep;
}
Beispiel #7
0
tofu_rep_t *handler_404(tofu_req_t *req) {
	tofu_rep_t *rep = tofu_rep_init();

	tofu_head(rep, "Content-Type", "text/html");
	tofu_write(rep, "<!DOCTYPE html>\n<head><title>404</title></head>\n");
	tofu_write(rep, "<body>Not found</body>\n");

	return rep;
}
Beispiel #8
0
tofu_rep_t *error_418(tofu_req_t *req) {
	tofu_rep_t *rep = tofu_rep_init();

	tofu_status(rep, 418);
	tofu_head(rep, "Content-Type", "text/html");
	tofu_write(rep, "<!DOCTYPE html>\n<head><title>I'm a teapot</title></head><body><h1>418 - Sorry, I'm just a teapot!</h1></body>\n");

	return rep;
}
Beispiel #9
0
tofu_rep_t *handler_root(tofu_req_t *req) {
	tofu_rep_t *rep = tofu_rep_init();

	tofu_head(rep, "Content-Type", "text/html");

	/* some random error occurred here */

	tofu_status(rep, 500);

	return rep;
}
Beispiel #10
0
tofu_rep_t *post_simple(tofu_req_t *req, void *argp) {
	tofu_rep_t *rep = tofu_rep_init();

	int body_len;
	char *body = tofu_body(req, &body_len);

	tofu_head(rep, "Content-Type", "text/html");
	tofu_writef(rep, "Hello %s!", body);

	return rep;
}
Beispiel #11
0
tofu_rep_t *post_param_multi(tofu_req_t *req, void *argp) {
	tofu_rep_t *rep = tofu_rep_init();

	int body_len;
	char *body = tofu_body(req, &body_len);

	char *param1 = tofu_param(req, "par1");
	char *param2 = tofu_param(req, "par2");

	tofu_head(rep, "Content-Type", "text/html");
	tofu_writef(rep, "The params are %s and %s, the body is %s", param1, param2, body);

	return rep;
}
Beispiel #12
0
tofu_rep_t *post_param(tofu_req_t *req, void *argp) {
	char *param;
	tofu_rep_t *rep = tofu_rep_init();

	int body_len;
	char *body = tofu_body(req, &body_len);

	param = tofu_param(req, "param");

	tofu_head(rep, "Content-Type", "text/html");
	tofu_writef(rep, "The param is %s and the body is %s", param, body);

	return rep;
}
Beispiel #13
0
tofu_rep_t *eg_handler(tofu_req_t *req) {
	tofu_rep_t *rep = tofu_rep_init();

	int body_len;
	char *body = tofu_body(req, &body_len);

	tofu_head(rep, "Content-Type", "text/html");
	tofu_write(rep, "<!DOCTYPE html>\n<head><title>POST</title></head>\n");

	if (body_len > 0)
		tofu_writef(rep, "<body>POST request: %s</body>\n", body);
	else
		tofu_write(rep, "<body>no body</body>\n");

	return rep;
}