Esempio n. 1
0
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	isAllowedToUpload := janitor.IsAllowedToUpload()
	if isAllowedToUpload == false {
		http.Error(w, "No upload allowed at this time", http.StatusForbidden)
		return
	}

	if r.Method == "POST" {
		h.streamUpload(w, r)
	} else if r.Method == "GET" {
		h.checkPart(w, r)
	} else {
		http.Error(w, "Method not suported", http.StatusMethodNotAllowed)
	}
}
Esempio n. 2
0
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	procede := janitor.IsAllowedToUpload()

	p := &procedeValue{}
	p.Procede = procede

	js, err := json.Marshal(p)
	if err != nil {
		h.log.Error(err)
		http.Error(w, "Internal Server Error", http.StatusInternalServerError)
		return
	}

	w.Header().Set("Content-Type", "application/json")
	w.Write(js)
}