From 4e03758e92887fe4251a73ce8125b93e8624b6a2 Mon Sep 17 00:00:00 2001 From: Ryan Mehri Date: Fri, 15 May 2020 19:00:21 -0600 Subject: Add comments and clean up encryption --- backend/api/routes.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'backend/api') diff --git a/backend/api/routes.go b/backend/api/routes.go index ff43714..474fdda 100644 --- a/backend/api/routes.go +++ b/backend/api/routes.go @@ -3,6 +3,7 @@ package api import ( "encoding/json" "fmt" + "github.com/jackyzha0/ctrl-v/security" "net/http" "time" @@ -87,6 +88,13 @@ func handleGetPaste(w http.ResponseWriter, r *http.Request, parsedPassword strin return } + // if internal error with encryption + if err == security.EncryptionError { + w.WriteHeader(http.StatusInternalServerError) + fmt.Fprintf(w, "%s", err) + return + } + // otherwise, return paste content, title, and current time w.Header().Set("Content-Type", "application/json") pasteMap := map[string]interface{}{ -- cgit v1.2.3