forked from wanelo/image-server
-
Notifications
You must be signed in to change notification settings - Fork 7
/
resize_many_handler.go
37 lines (31 loc) · 1.07 KB
/
resize_many_handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package server
import (
"net/http"
"strings"
"github.com/gorilla/mux"
"github.com/image-server/image-server/core"
"github.com/image-server/image-server/uploader"
"github.com/image-server/image-server/request"
)
// ResizeManyHandler asumes the original image is either stores locally or on the remote server
// It returns status code 200 and no content
// A listing will be requested to the uploader to determine what images are missing, and only
// Images not already processed will be generated and uploaded
func ResizeManyHandler(w http.ResponseWriter, req *http.Request, sc *core.ServerConfiguration) {
qs := req.URL.Query()
vars := mux.Vars(req)
ir := request.Request{
ServerConfiguration: sc,
Namespace: vars["namespace"],
Outputs: strings.Split(qs.Get("outputs"), ","),
Uploader: uploader.DefaultUploader(sc),
Paths: sc.Adapters.Paths,
Hash: varsToHash(vars),
}
err := ir.ProcessMultiple()
if err != nil {
errorHandlerJSON(err, w, http.StatusInternalServerError)
return
}
w.WriteHeader(200)
}