aboutsummaryrefslogtreecommitdiff
path: root/backend/api
diff options
context:
space:
mode:
authorRyan Mehri <[email protected]>2020-05-15 19:00:21 -0600
committerRyan Mehri <[email protected]>2020-05-15 19:00:21 -0600
commit4e03758e92887fe4251a73ce8125b93e8624b6a2 (patch)
tree7afe72a155fd9f6afd1bdded4a214b6fbba77fa0 /backend/api
parentAdd encryption to content when password is specified (diff)
downloadctrl-v-4e03758e92887fe4251a73ce8125b93e8624b6a2.tar.xz
ctrl-v-4e03758e92887fe4251a73ce8125b93e8624b6a2.zip
Add comments and clean up encryption
Diffstat (limited to 'backend/api')
-rw-r--r--backend/api/routes.go8
1 files changed, 8 insertions, 0 deletions
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{}{