diff options
| author | Ryan Mehri <[email protected]> | 2020-05-09 22:30:14 -0600 |
|---|---|---|
| committer | Ryan Mehri <[email protected]> | 2020-05-09 22:30:14 -0600 |
| commit | 4bb46084477c9f6fba93d84a7feea2ba63804362 (patch) | |
| tree | 1beda0f732febffec221b1d372b1dc75167900b1 | |
| parent | Merge pull request #5 from jackyzha0/react (diff) | |
| download | ctrl-v-4bb46084477c9f6fba93d84a7feea2ba63804362.tar.xz ctrl-v-4bb46084477c9f6fba93d84a7feea2ba63804362.zip | |
Add title to post
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | backend/api/routes.go | 3 | ||||
| -rw-r--r-- | backend/db/db.go | 5 | ||||
| -rw-r--r-- | backend/db/schemas.go | 1 |
4 files changed, 7 insertions, 4 deletions
@@ -1,4 +1,4 @@ -.env +backend/.env .idea go.sum .DS_Store diff --git a/backend/api/routes.go b/backend/api/routes.go index 760ee35..ef8ccf7 100644 --- a/backend/api/routes.go +++ b/backend/api/routes.go @@ -22,6 +22,7 @@ func insertFunc(w http.ResponseWriter, r *http.Request) { _ = r.ParseMultipartForm(0) expiry := r.FormValue("expiry") content := r.FormValue("content") + title := r.FormValue("title") // get ip ip := getIP(r) @@ -29,7 +30,7 @@ func insertFunc(w http.ResponseWriter, r *http.Request) { log.Infof("got content '%s' and ip '%s'", content, ip) // insert content - err := db.New(ip, content, expiry) + err := db.New(ip, content, expiry, title) if err != nil { fmt.Fprintf(w, "got err: %s", err.Error()) } diff --git a/backend/db/db.go b/backend/db/db.go index 053ba87..4f638fd 100644 --- a/backend/db/db.go +++ b/backend/db/db.go @@ -24,8 +24,8 @@ func init() { initSessions(mUser, mPass, mIP) } -// creates a new paste with content and hash -func New(ip, content, expiry string) error { +// creates a new paste with title, content and hash +func New(ip, content, expiry, title string) error { // generate hash from ip hash := hashing.GenerateURI(ip) @@ -33,6 +33,7 @@ func New(ip, content, expiry string) error { new := Paste{ Hash: hash, Content: content, + Title: title, } // check if expiry diff --git a/backend/db/schemas.go b/backend/db/schemas.go index bdfa60c..62c5a11 100644 --- a/backend/db/schemas.go +++ b/backend/db/schemas.go @@ -12,4 +12,5 @@ type Paste struct { Hash string Content string Expiry time.Time `bson:"expiry"` + Title string } |