Huge rework to more modern code

This commit is contained in:
nemunaire 2022-09-04 21:45:39 +02:00
commit 4fcf12dff2
8 changed files with 288 additions and 174 deletions

View file

@ -10,10 +10,10 @@ type imagesHandler struct {
name string
auth func(*http.Request) bool
hndlr http.Handler
getter func(fname string) (Picture, error)
getter func(fname string) (*Picture, error)
}
func ImagesHandler(name string, auth func(*http.Request) bool, hndlr http.Handler, getter func(fname string) (Picture, error)) imagesHandler {
func ImagesHandler(name string, auth func(*http.Request) bool, hndlr http.Handler, getter func(fname string) (*Picture, error)) imagesHandler {
return imagesHandler{name, auth, hndlr, getter}
}
@ -50,7 +50,7 @@ func (i imagesHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusNotFound)
return
} else {
r.URL.Path = "/" + pict.basename
r.URL.Path = "/" + pict.path
i.hndlr.ServeHTTP(w, r)
}
}