Contains the Concourse pipeline definition for building a line-server container
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.

34 lines
628 B

  1. package main
  2. import (
  3. "net/http"
  4. "os"
  5. "path"
  6. "github.com/zenazn/goji/web"
  7. )
  8. func fileServeHandler(c web.C, w http.ResponseWriter, r *http.Request) {
  9. fileName := c.URLParams["name"]
  10. filePath := path.Join(Config.filesDir, fileName)
  11. _, err := os.Stat(filePath)
  12. if os.IsNotExist(err) {
  13. notFoundHandler(c, w, r)
  14. return
  15. }
  16. expired, expErr := isFileExpired(fileName)
  17. if expErr != nil {
  18. // Error reading metadata, pretend it's expired
  19. notFoundHandler(c, w, r)
  20. // TODO log error internally
  21. return
  22. } else if expired {
  23. notFoundHandler(c, w, r)
  24. // TODO delete the file
  25. }
  26. http.ServeFile(w, r, filePath)
  27. }