-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (31 loc) · 1.3 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"log"
"net/http"
"restapi/controller"
_ "github.com/go-sql-driver/mysql"
"github.com/gorilla/mux"
)
func main() {
router := mux.NewRouter()
router.HandleFunc("/users", controller.ReturnAllUsers).Methods("GET")
router.HandleFunc("/users", controller.InsertUsersMultipart).Methods("POST")
router.HandleFunc("/users", controller.UpdateUsersMultipart).Methods("PUT")
router.HandleFunc("/users", controller.DeleteUsersMultipart).Methods("DELETE")
//LoginApi
router.HandleFunc("/users/login", controller.GetLogin).Methods("POST")
router.HandleFunc("/users/cek-session", controller.CekUserSession).Methods("GET")
router.HandleFunc("/users/logout", controller.GoLogout).Methods("GET")
//Get Produk
router.HandleFunc("/cekproduk", controller.GetProduk).Methods("POST")
router.HandleFunc("/getbarang", controller.GetBarangByProduk).Methods("POST")
//GetOrder
router.HandleFunc("/order", controller.GetOrder).Methods("POST")
router.HandleFunc("/riwayatorder", controller.RiwayatTransaksi).Methods("POST")
router.HandleFunc("/bayarorder", controller.BayarOrder).Methods("POST")
router.HandleFunc("/riwayatorderid", controller.RiwayatTransaksiById).Methods("POST")
http.Handle("/", router)
fmt.Println("Connected to port 1234")
log.Fatal(http.ListenAndServe(":1234", router))
}