add a redirect query for no javascript
This commit is contained in:
+10
@@ -62,6 +62,10 @@ func uploadHandler(db *gorm.DB, cfg Config) http.HandlerFunc {
|
||||
if r.URL.Query().Get("idlength") == "short" {
|
||||
idLength = 10
|
||||
}
|
||||
redirect := false
|
||||
if r.URL.Query().Get("redirect") == "true" {
|
||||
redirect = true
|
||||
}
|
||||
|
||||
var input UploadInput
|
||||
switch mediaType {
|
||||
@@ -202,6 +206,12 @@ func uploadHandler(db *gorm.DB, cfg Config) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
saved = true
|
||||
|
||||
if redirect {
|
||||
http.Redirect(w, r, "/"+id, http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
if err := json.NewEncoder(w).Encode(UploadResponse{
|
||||
|
||||
Reference in New Issue
Block a user