MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / Images

Function Images

src/webserver.go:500–519  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

498}
499
500func Images(w http.ResponseWriter, r *http.Request) {
501
502 var path = strings.TrimPrefix(r.URL.Path, "/")
503 systemMutex.Lock()
504 filePath := System.Folder.ImagesCache + getFilenameFromPath(path)
505 systemMutex.Unlock()
506
507 content, err := readByteFromFile(filePath)
508 if err != nil {
509 httpStatusError(w, r, 404)
510 return
511 }
512
513 w.Header().Add("Content-Type", getContentType(filePath))
514 w.Header().Add("Content-Length", fmt.Sprintf("%d", len(content)))
515 w.WriteHeader(200)
516 w.Write(content)
517
518 return
519}
520
521func DataImages(w http.ResponseWriter, r *http.Request) {
522

Callers

nothing calls this directly

Calls 4

readByteFromFileFunction · 0.85
httpStatusErrorFunction · 0.85
getContentTypeFunction · 0.85
getFilenameFromPathFunction · 0.70

Tested by

no test coverage detected