arimelody.me/global/global.go
ari melody 5631c4bd87 added stuff, broke some other stuff, made admin auth!
Signed-off-by: ari melody <ari@arimelody.me>
2024-08-31 01:52:31 +01:00

35 lines
765 B
Go

package global
import (
"net/http"
"time"
)
var LAST_MODIFIED = time.Now()
var MimeTypes = map[string]string{
"css": "text/css; charset=utf-8",
"png": "image/png",
"jpg": "image/jpg",
"webp": "image/webp",
"html": "text/html",
"asc": "text/plain",
"pub": "text/plain",
"js": "application/javascript",
}
func IsModified(req *http.Request, last_modified time.Time) bool {
if len(req.Header["If-Modified-Since"]) == 0 || len(req.Header["If-Modified-Since"][0]) == 0 {
return true
}
request_time, err := time.Parse(http.TimeFormat, req.Header["If-Modified-Since"][0])
if err != nil {
return true
}
if request_time.Before(last_modified) {
return true
}
return false
}