aboutsummaryrefslogtreecommitdiff
path: root/backend/api/routes.go
diff options
context:
space:
mode:
authorJacky Zhao <[email protected]>2020-05-15 18:53:37 -0700
committerGitHub <[email protected]>2020-05-15 18:53:37 -0700
commit2e4a87393d6fdf0320696faedecdc7699289fffb (patch)
tree7afe72a155fd9f6afd1bdded4a214b6fbba77fa0 /backend/api/routes.go
parentMerge pull request #24 from jackyzha0/update-readme (diff)
parentAdd comments and clean up encryption (diff)
downloadctrl-v-2e4a87393d6fdf0320696faedecdc7699289fffb.tar.xz
ctrl-v-2e4a87393d6fdf0320696faedecdc7699289fffb.zip
Merge pull request #25 from jackyzha0/security
Add encryption to content when password is specified
Diffstat (limited to 'backend/api/routes.go')
-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{}{