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.
|
|
package main
import ( "fmt" "net/http" "os" "path"
"github.com/zenazn/goji/web" )
func deleteHandler(c web.C, w http.ResponseWriter, r *http.Request) { requestKey := r.Header.Get("Linx-Delete-Key")
filename := c.URLParams["name"] filePath := path.Join(Config.filesDir, filename) metaPath := path.Join(Config.metaDir, filename)
// Ensure requested file actually exists
if _, readErr := os.Stat(filePath); os.IsNotExist(readErr) { notFoundHandler(c, w, r) // 404 - file doesn't exist
return }
// Ensure delete key is correct
metadata, err := metadataRead(filename) if err != nil { unauthorizedHandler(c, w, r) // 401 - no metadata available
return }
if metadata.DeleteKey == requestKey { fileDelErr := os.Remove(filePath) metaDelErr := os.Remove(metaPath)
if (fileDelErr != nil) || (metaDelErr != nil) { oopsHandler(c, w, r, RespPLAIN, "Could not delete") return }
fmt.Fprintf(w, "DELETED") return
} else { unauthorizedHandler(c, w, r) // 401 - wrong delete key
return } }
|