-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
31 lines (24 loc) · 786 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"encoding/json"
"log"
"net/http"
"strconv"
"github.com/arturoverbel/microservice_compra/connection"
"github.com/arturoverbel/microservice_compra/model"
"github.com/gorilla/mux"
"gopkg.in/mgo.v2/bson"
)
var prefixPath = "/api/compra"
func main() {
r := mux.NewRouter()
r.HandleFunc(prefixPath, CreateShoppingController).Methods("POST")
r.HandleFunc(prefixPath, UpdateShoppingController).Methods("PUT")
r.HandleFunc(prefixPath, DeleteShoppingController).Methods("DELETE")
r.HandleFunc(prefixPath+"/{id}", FindShoppingByIDController).Methods("GET")
r.HandleFunc(prefixPath+"/by-user/{id_user}", FindShoppingByUserController).Methods("GET")
log.Printf("Listening...")
if err := http.ListenAndServe(":3000", r); err != nil {
log.Fatal(err)
}
}