forked from electricdusk/rushlink
parent
ba08aca622
commit
40a32fa535
@ -67,6 +67,10 @@ func (rl *rushlink) uploadFileGetHandler(w http.ResponseWriter, r *http.Request)
|
||||
panic(err)
|
||||
}
|
||||
w.Header().Set("Content-Type", fu.ContentType)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
if r.Method == "HEAD" {
|
||||
return
|
||||
}
|
||||
io.Copy(w, file)
|
||||
}
|
||||
|
||||
|
10
router.go
10
router.go
@ -79,14 +79,14 @@ func StartMainServer(addr string, db *db.Database, fs *db.FileStore) {
|
||||
router := mux.NewRouter()
|
||||
router.Use(recoveryMiddleware)
|
||||
router.Use(metricsMiddleware)
|
||||
router.HandleFunc("/", rl.indexGetHandler).Methods("GET")
|
||||
router.HandleFunc("/", rl.indexGetHandler).Methods("GET", "HEAD")
|
||||
router.HandleFunc("/", rl.newPasteHandler).Methods("POST")
|
||||
router.HandleFunc("/{key:[A-Za-z0-9-_]{4,}}", rl.viewPasteHandler).Methods("GET")
|
||||
router.HandleFunc("/{key:[A-Za-z0-9-_]{4,}}/nr", rl.viewPasteHandlerNoRedirect).Methods("GET")
|
||||
router.HandleFunc("/{key:[A-Za-z0-9-_]{4,}}/meta", rl.viewPasteHandlerMeta).Methods("GET")
|
||||
router.HandleFunc("/{key:[A-Za-z0-9-_]{4,}}", rl.viewPasteHandler).Methods("GET", "HEAD")
|
||||
router.HandleFunc("/{key:[A-Za-z0-9-_]{4,}}/nr", rl.viewPasteHandlerNoRedirect).Methods("GET", "HEAD")
|
||||
router.HandleFunc("/{key:[A-Za-z0-9-_]{4,}}/meta", rl.viewPasteHandlerMeta).Methods("GET", "HEAD")
|
||||
router.HandleFunc("/{key:[A-Za-z0-9-_]{4,}}", rl.deletePasteHandler).Methods("DELETE")
|
||||
router.HandleFunc("/{key:[A-Za-z0-9-_]{4,}}/delete", rl.deletePasteHandler).Methods("POST")
|
||||
router.HandleFunc("/uploads/{id:[A-Za-z0-9-_]+}/{filename:.+}", rl.uploadFileGetHandler).Methods("GET")
|
||||
router.HandleFunc("/uploads/{id:[A-Za-z0-9-_]+}/{filename:.+}", rl.uploadFileGetHandler).Methods("GET", "HEAD")
|
||||
|
||||
srv := &http.Server{
|
||||
Handler: router,
|
||||
|
Loading…
Reference in New Issue
Block a user