preview: accept context parameter

This commit is contained in:
mappu 2023-05-19 19:13:31 +12:00
parent 01ff8f69aa
commit 15c02efe96
2 changed files with 3 additions and 2 deletions

View File

@ -161,7 +161,7 @@ func (this *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
this.handleInformation(w, r.URL.Path[len(metadataUrlPrefix):]) this.handleInformation(w, r.URL.Path[len(metadataUrlPrefix):])
} else if r.Method == "GET" && strings.HasPrefix(r.URL.Path, previewUrlPrefix) { } else if r.Method == "GET" && strings.HasPrefix(r.URL.Path, previewUrlPrefix) {
this.handlePreview(w, r.URL.Path[len(previewUrlPrefix):]) this.handlePreview(r.Context(), w, r.URL.Path[len(previewUrlPrefix):])
} else if r.Method == "GET" && rxThumbUrl.MatchString(r.URL.Path) { } else if r.Method == "GET" && rxThumbUrl.MatchString(r.URL.Path) {
parts := rxThumbUrl.FindStringSubmatch(r.URL.Path) parts := rxThumbUrl.FindStringSubmatch(r.URL.Path)

View File

@ -1,6 +1,7 @@
package contented package contented
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"html" "html"
@ -12,7 +13,7 @@ import (
"time" "time"
) )
func (this *Server) handlePreview(w http.ResponseWriter, fileIDList string) { func (this *Server) handlePreview(ctx context.Context, w http.ResponseWriter, fileIDList string) {
fileIDs := strings.Split(fileIDList, `-`) fileIDs := strings.Split(fileIDList, `-`)