2024-08-03 20:05:08 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2024-08-15 02:53:02 +02:00
|
|
|
"strings"
|
|
|
|
"log"
|
2024-08-03 20:05:08 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func (ctx *ServerContext) HandleFile(w http.ResponseWriter, req *http.Request) error {
|
|
|
|
ctx.WG.Add(1)
|
|
|
|
defer ctx.WG.Done()
|
2024-08-15 02:53:02 +02:00
|
|
|
log.Println("requested file ", req.URL.Path)
|
|
|
|
if strings.HasPrefix(req.URL.Path, "/file/") {
|
|
|
|
http.ServeFile(w, req, ctx.Config.FileRoot + "/" + req.URL.Path[6:]);
|
|
|
|
}
|
2024-08-03 20:05:08 +02:00
|
|
|
return nil
|
|
|
|
}
|