diff options
| author | Jacky Zhao <[email protected]> | 2020-05-15 18:53:37 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-05-15 18:53:37 -0700 |
| commit | 2e4a87393d6fdf0320696faedecdc7699289fffb (patch) | |
| tree | 7afe72a155fd9f6afd1bdded4a214b6fbba77fa0 /backend/api/routes.go | |
| parent | Merge pull request #24 from jackyzha0/update-readme (diff) | |
| parent | Add comments and clean up encryption (diff) | |
| download | ctrl-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.go | 8 |
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{}{ |