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

Function DataImages

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

Source from the content-addressed store, hash-verified

519}
520
521func DataImages(w http.ResponseWriter, r *http.Request) {
522
523 var path = strings.TrimPrefix(r.URL.Path, "/")
524 systemMutex.Lock()
525 filePath := System.Folder.ImagesUpload + getFilenameFromPath(path)
526 systemMutex.Unlock()
527
528 content, err := readByteFromFile(filePath)
529 if err != nil {
530 httpStatusError(w, r, 404)
531 return
532 }
533
534 w.Header().Add("Content-Type", getContentType(filePath))
535 w.Header().Add("Content-Length", fmt.Sprintf("%d", len(content)))
536 w.WriteHeader(200)
537 w.Write(content)
538
539 return
540}
541
542func WS(w http.ResponseWriter, r *http.Request) {
543

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