Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • main
  • ui-rewrite
2 results

Target

Select target project
  • justJanne/imghost
1 result
Select Git revision
  • main
  • ui-rewrite
2 results
Show changes
Commits on Source (2)
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
"build": "npm run sass" "build": "npm run sass"
}, },
"devDependencies": { "devDependencies": {
"node-sass": "^4.7.2" "node-sass": "^4.10.0"
} }
} }
...@@ -2,12 +2,22 @@ package main ...@@ -2,12 +2,22 @@ package main
import ( import (
"net/http" "net/http"
"strings"
) )
type IndexData struct { type IndexData struct {
User UserInfo User UserInfo
} }
func removeFileExtensions(path string) string {
var i = strings.IndexByte(path, '.')
if i < 0 {
return path
} else {
return path[0:i]
}
}
func pageIndex(ctx PageContext) http.Handler { func pageIndex(ctx PageContext) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" { if r.URL.Path == "/" {
...@@ -33,6 +43,7 @@ func pageIndex(ctx PageContext) http.Handler { ...@@ -33,6 +43,7 @@ func pageIndex(ctx PageContext) http.Handler {
} else { } else {
w.Header().Set("Vary", "Accept-Encoding") w.Header().Set("Vary", "Accept-Encoding")
w.Header().Set("Cache-Control", "public, max-age=31536000") w.Header().Set("Cache-Control", "public, max-age=31536000")
r.URL.Path = removeFileExtensions(r.URL.Path)
ctx.Images.ServeHTTP(w, r) ctx.Images.ServeHTTP(w, r)
} }
}) })
......