Handle static files! (Should only be used as a fallback if static files are not handled by httpd)
This commit is contained in:
parent
24920f1c81
commit
79c07a8d23
1 changed files with 22 additions and 0 deletions
22
bin/werc.rc
22
bin/werc.rc
|
|
@ -116,6 +116,28 @@ fn select_handler {
|
||||||
if not if(~ $local_path *.html && test -f $local_path)
|
if not if(~ $local_path *.html && test -f $local_path)
|
||||||
perm_redirect `{ echo $req_path|sed 's/.html$//' }
|
perm_redirect `{ echo $req_path|sed 's/.html$//' }
|
||||||
|
|
||||||
|
# Fallback static file handler
|
||||||
|
if not if(test -f $local_path) {
|
||||||
|
m='text/plain'
|
||||||
|
if(~ $req_path *.css)
|
||||||
|
m='text/css'
|
||||||
|
if not if(~ $req_path *.ico)
|
||||||
|
m='image/x-icon'
|
||||||
|
if not if(~ $req_path *.png)
|
||||||
|
m='image/png'
|
||||||
|
if not if(~ $req_path *.jpg *.jpeg)
|
||||||
|
m='image/jpeg'
|
||||||
|
if not if(~ $req_path *.gif)
|
||||||
|
m='image/gif'
|
||||||
|
if not if(~ $req_path *.pdf)
|
||||||
|
m='application/pdf'
|
||||||
|
|
||||||
|
echo 'Content-Type: '^$m
|
||||||
|
echo
|
||||||
|
cat $local_path
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
# File not found
|
# File not found
|
||||||
if not {
|
if not {
|
||||||
set_handler tpl_handler `{get_lib_file 404.tpl}
|
set_handler tpl_handler `{get_lib_file 404.tpl}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue