link parse fx1
This commit is contained in:
parent
f08c94c614
commit
73b24388c8
|
|
@ -48,7 +48,12 @@ func ParseLink(w http.ResponseWriter, route *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportProduct(jsonProduct, baza)
|
err = ImportProduct(jsonProduct, baza)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
helper.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
json.NewEncoder(w).Encode(map[string]string{
|
json.NewEncoder(w).Encode(map[string]string{
|
||||||
|
|
|
||||||
23
main.go
23
main.go
|
|
@ -2,14 +2,18 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"db_service/controllers"
|
"db_service/controllers"
|
||||||
|
helper "db_service/pkg"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
|
"github.com/leesper/couchdb-golang"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
// logging setup
|
||||||
|
helper.Setup()
|
||||||
|
|
||||||
log.Println("init function")
|
log.Println("init function")
|
||||||
|
|
||||||
|
|
@ -18,6 +22,25 @@ func init() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
// initialize couch db
|
||||||
|
err = InitCouchDbServer()
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitCouchDbServer() error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
helper.CdbServer, err = couchdb.NewServer(os.Getenv("couch_db_source"))
|
||||||
|
if err != nil {
|
||||||
|
helper.Error(err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
version, err := helper.CdbServer.Version()
|
||||||
|
if err != nil {
|
||||||
|
helper.Error("couchdb not initialized. ", err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
helper.Info("couchdb running with version " + version)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue