(rw http.ResponseWriter, req *http.Request)
| 545 | } |
| 546 | |
| 547 | func (ui *UIHandler) serveThumbnail(rw http.ResponseWriter, req *http.Request) { |
| 548 | if ui.root.Storage == nil { |
| 549 | http.Error(rw, "No BlobRoot configured", 500) |
| 550 | return |
| 551 | } |
| 552 | |
| 553 | suffix := httputil.PathSuffix(req) |
| 554 | m := thumbnailPattern.FindStringSubmatch(suffix) |
| 555 | if m == nil { |
| 556 | httputil.ErrorRouting(rw, req) |
| 557 | return |
| 558 | } |
| 559 | |
| 560 | query := req.URL.Query() |
| 561 | width, _ := strconv.Atoi(query.Get("mw")) |
| 562 | height, _ := strconv.Atoi(query.Get("mh")) |
| 563 | blobref, ok := blob.Parse(m[1]) |
| 564 | if !ok { |
| 565 | http.Error(rw, "Invalid blobref", http.StatusBadRequest) |
| 566 | return |
| 567 | } |
| 568 | |
| 569 | if width == 0 { |
| 570 | width = search.MaxImageSize |
| 571 | } |
| 572 | if height == 0 { |
| 573 | height = search.MaxImageSize |
| 574 | } |
| 575 | |
| 576 | th := &ImageHandler{ |
| 577 | Fetcher: ui.root.Storage, |
| 578 | Cache: ui.Cache, |
| 579 | MaxWidth: width, |
| 580 | MaxHeight: height, |
| 581 | ThumbMeta: ui.thumbMeta, |
| 582 | ResizeSem: ui.resizeSem, |
| 583 | Search: ui.search, |
| 584 | } |
| 585 | th.ServeHTTP(rw, req, blobref) |
| 586 | } |
| 587 | |
| 588 | func (ui *UIHandler) serveFileTree(rw http.ResponseWriter, req *http.Request) { |
| 589 | if ui.root.Storage == nil { |
no test coverage detected