aboutsummaryrefslogtreecommitdiff
path: root/api/routes.go
diff options
context:
space:
mode:
authorjackyzha0 <[email protected]>2020-05-09 14:28:24 -0700
committerjackyzha0 <[email protected]>2020-05-09 14:28:24 -0700
commit35ce1bff3496c67cda124aea3c36bc5b66b1e4e6 (patch)
tree6dedc5d47077ff9831f2e944bc83dd957eb3f894 /api/routes.go
parentMerge pull request #1 from jackyzha0/hash (diff)
downloadctrl-v-35ce1bff3496c67cda124aea3c36bc5b66b1e4e6.tar.xz
ctrl-v-35ce1bff3496c67cda124aea3c36bc5b66b1e4e6.zip
working mongo doc add
Diffstat (limited to 'api/routes.go')
-rw-r--r--api/routes.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/api/routes.go b/api/routes.go
index edb5a02..655d18b 100644
--- a/api/routes.go
+++ b/api/routes.go
@@ -3,8 +3,29 @@ package api
import (
"fmt"
"net/http"
+
+ "github.com/jackyzha0/ctrl-v/db"
+
+ log "github.com/sirupsen/logrus"
)
func healthCheckFunc(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintf(w, "status ok")
+ fmt.Fprint(w, "status ok")
+}
+
+func insertFunc(w http.ResponseWriter, r *http.Request) {
+ // get content
+ _ = r.ParseMultipartForm(0)
+ content := r.FormValue("content")
+
+ // get ip
+ ip, _ := getIP(r)
+
+ log.Infof("got content `%s` and ip %s", content, ip)
+
+ // insert content
+ err := db.New(ip, content)
+ if err != nil {
+ fmt.Fprintf(w, "got err: %s", err.Error())
+ }
}