|
|
@ -54,15 +54,20 @@ func (ctx *SubmitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
|
|
|
Created: time.Now(), |
|
|
|
} |
|
|
|
|
|
|
|
err := ctx.Storage.AddQURL(q) |
|
|
|
err := q.CheckValid() |
|
|
|
if err != nil { |
|
|
|
http.Error(w, fmt.Sprintf("Database error: %s", err.Error()), |
|
|
|
http.StatusInternalServerError) |
|
|
|
return |
|
|
|
} |
|
|
|
pg.Message = err.Error() |
|
|
|
} else { |
|
|
|
err := ctx.Storage.AddQURL(q) |
|
|
|
if err != nil { |
|
|
|
http.Error(w, fmt.Sprintf("Database error: %s", err.Error()), |
|
|
|
http.StatusInternalServerError) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
pg.Message = "URL Added." |
|
|
|
pg.URL = fmt.Sprintf("https://qurl.org/%s", qurl.ToString(q.ID)) |
|
|
|
pg.Message = "URL Added." |
|
|
|
pg.URL = fmt.Sprintf("https://qurl.org/%s", qurl.ToString(q.ID)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|