diff options
Diffstat (limited to 'backend/api')
| -rw-r--r-- | backend/api/routes.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/backend/api/routes.go b/backend/api/routes.go index d578632..f41505b 100644 --- a/backend/api/routes.go +++ b/backend/api/routes.go @@ -52,9 +52,16 @@ func getHashFunc(w http.ResponseWriter, r *http.Request) { paste, err := cache.C.Get(hash) // if hash was not found - if err != nil { + if err == cache.PasteNotFound { w.WriteHeader(http.StatusNotFound) - fmt.Fprintf(w, "got err: %s", err.Error()) + fmt.Fprintf(w, "got err: %s", err) + return + } + + // if paste is password protected + if err == cache.UserUnauthorized { + w.WriteHeader(http.StatusUnauthorized) + fmt.Fprintf(w, "got err: %s", err) return } @@ -64,6 +71,7 @@ func getHashFunc(w http.ResponseWriter, r *http.Request) { "timestamp": time.Now(), "title": paste.Title, "content": paste.Content, + "expiry": paste.Expiry, } jsonData, _ := json.Marshal(pasteMap) |