Ejemplo n.º 1
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;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
Archivo: status.c Proyecto: jackey/Tofu
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;
}
Ejemplo n.º 6
0
Archivo: status.c Proyecto: jackey/Tofu
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;
}
Ejemplo n.º 7
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;
}