go-podcast-proxy/handle-file.go

17 lines
395 B
Go

package main
import (
"net/http"
"strings"
"log"
)
func (ctx *ServerContext) HandleFile(w http.ResponseWriter, req *http.Request) error {
ctx.WG.Add(1)
defer ctx.WG.Done()
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:]);
}
return nil
}