-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (30 loc) · 1.03 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
package main
import (
"fmt"
"net/http"
"github.com/gorilla/mux"
user_api "./apis/user_api"
post_api "./apis/post_api"
comment_api "./apis/comment_api"
"./migration"
)
func HandleRequests() {
router:=mux.NewRouter().StrictSlash(true)
router.HandleFunc("/api/user/register", user_api.Register).Methods("POST")
router.HandleFunc("/api/user/login", user_api.Login).Methods("POST")
router.HandleFunc("/api/user", user_api.Users).Methods("GET")
router.HandleFunc("/api/user",user_api.UserUpdate).Methods("PATCH")
router.HandleFunc("/api/user/password",user_api.UserUpdatePassword).Methods("PATCH")
router.HandleFunc("/api/post",post_api.PostCreate).Methods("POST")
router.HandleFunc("/api/post",post_api.PostDelete).Methods("DELETE")
router.HandleFunc("/api/comment",comment_api.CommentCreate).Methods("POST")
router.HandleFunc("/api/comment",comment_api.CommentDelete).Methods("DELETE")
err:=http.ListenAndServe(":5000", router)
if err!=nil {
fmt.Println(err)
}
}
func main() {
migration.InitialMigration()
HandleRequests()
}