You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
417 B
24 lines
417 B
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
"path"
|
|
|
|
"github.com/zenazn/goji/web"
|
|
)
|
|
|
|
func fileServeHandler(c web.C, w http.ResponseWriter, r *http.Request) {
|
|
filename := c.URLParams["name"]
|
|
absPath := path.Join(Config.filesDir, filename)
|
|
_, err := os.Stat(absPath)
|
|
|
|
if os.IsNotExist(err) {
|
|
http.Error(w, http.StatusText(404), 404)
|
|
return
|
|
}
|
|
|
|
// plug file expiry checking here
|
|
|
|
http.ServeFile(w, r, absPath)
|
|
}
|