mirror of https://git.kore.io/kore.git
move static assets to use asset_serve_* in generic.
note that certain browsers change their caching behaviour when you are connecting over TLS using self-signed certificates. reminded by #179
This commit is contained in:
parent
175b2e2c9b
commit
edd7a10773
|
@ -6,6 +6,10 @@ cflags=-Wall -Wmissing-declarations -Wshadow
|
|||
cflags=-Wstrict-prototypes -Wmissing-prototypes
|
||||
cflags=-Wpointer-arith -Wcast-qual -Wsign-compare
|
||||
|
||||
mime_add=jpg:image/jpg
|
||||
mime_add=css:text/css; charset=utf-8
|
||||
mime_add=html:text/html; charset=utf-8
|
||||
|
||||
dev {
|
||||
# These cflags are added to the shared ones when
|
||||
# you build the "dev" flavor.
|
||||
|
|
|
@ -25,16 +25,16 @@ domain 127.0.0.1 {
|
|||
certkey cert/key.pem
|
||||
accesslog kore_access.log
|
||||
|
||||
static /css/style.css serve_style_css
|
||||
static / serve_index
|
||||
static /intro.jpg serve_intro
|
||||
static /css/style.css asset_serve_style_css
|
||||
static / asset_serve_index_html
|
||||
static /intro.jpg asset_serve_intro_jpg
|
||||
static /b64test serve_b64test
|
||||
static /upload serve_file_upload
|
||||
static /validator serve_validator
|
||||
static /params-test serve_params_test
|
||||
static /private serve_private
|
||||
|
||||
static /private/test serve_private_test auth_example
|
||||
static /private/test asset_serve_private_test_html auth_example
|
||||
|
||||
params post /params-test {
|
||||
validate test1 v_example
|
||||
|
|
|
@ -27,9 +27,6 @@
|
|||
|
||||
int example_load(int);
|
||||
|
||||
int serve_style_css(struct http_request *);
|
||||
int serve_index(struct http_request *);
|
||||
int serve_intro(struct http_request *);
|
||||
int serve_b64test(struct http_request *);
|
||||
int serve_file_upload(struct http_request *);
|
||||
int serve_validator(struct http_request *);
|
||||
|
@ -73,50 +70,6 @@ example_load(int state)
|
|||
return (KORE_RESULT_OK);
|
||||
}
|
||||
|
||||
int
|
||||
serve_style_css(struct http_request *req)
|
||||
{
|
||||
char *date;
|
||||
time_t tstamp;
|
||||
|
||||
tstamp = 0;
|
||||
if (http_request_header(req, "if-modified-since", &date)) {
|
||||
tstamp = kore_date_to_time(date);
|
||||
kore_debug("header was present with %ld", tstamp);
|
||||
}
|
||||
|
||||
if (tstamp != 0 && tstamp <= asset_mtime_style_css) {
|
||||
http_response(req, 304, NULL, 0);
|
||||
} else {
|
||||
date = kore_time_to_date(asset_mtime_style_css);
|
||||
if (date != NULL)
|
||||
http_response_header(req, "last-modified", date);
|
||||
|
||||
http_response_header(req, "content-type", "text/css");
|
||||
http_response(req, 200, asset_style_css, asset_len_style_css);
|
||||
}
|
||||
|
||||
return (KORE_RESULT_OK);
|
||||
}
|
||||
|
||||
int
|
||||
serve_index(struct http_request *req)
|
||||
{
|
||||
http_response_header(req, "content-type", "text/html");
|
||||
http_response(req, 200, asset_index_html, asset_len_index_html);
|
||||
|
||||
return (KORE_RESULT_OK);
|
||||
}
|
||||
|
||||
int
|
||||
serve_intro(struct http_request *req)
|
||||
{
|
||||
http_response_header(req, "content-type", "image/jpg");
|
||||
http_response(req, 200, asset_intro_jpg, asset_len_intro_jpg);
|
||||
|
||||
return (KORE_RESULT_OK);
|
||||
}
|
||||
|
||||
int
|
||||
serve_b64test(struct http_request *req)
|
||||
{
|
||||
|
@ -315,17 +268,6 @@ serve_private(struct http_request *req)
|
|||
return (KORE_RESULT_OK);
|
||||
}
|
||||
|
||||
int
|
||||
serve_private_test(struct http_request *req)
|
||||
{
|
||||
http_response_header(req, "content-type", "text/html");
|
||||
|
||||
http_response(req, 200, asset_private_test_html,
|
||||
asset_len_private_test_html);
|
||||
|
||||
return (KORE_RESULT_OK);
|
||||
}
|
||||
|
||||
int
|
||||
v_example_func(struct http_request *req, char *data)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue