-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (28 loc) · 811 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
32
33
34
35
36
37
38
39
40
41
package main
import (
"net/http"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
"github.com/sudachi0114/web-db-docker/handler"
"github.com/sudachi0114/web-db-docker/repo"
)
func main() {
DBMS := "mysql"
CONNECTION := "test:passw0rd@tcp(db:3306)/test_db?charset=utf8&parseTime=true&loc=Asia%2FTokyo"
db := repo.Connect(DBMS, CONNECTION)
defer db.Close()
r := gin.Default()
r.LoadHTMLGlob("templates/*.html")
r.GET("/", handler.ResponseWithTemplate)
r.GET("/ping", handler.ResponseByJson)
r.POST("/new_user", handler.CreateUser)
r.GET("/get_all_users", handler.GetAllUser)
r.GET("/get_user/:id", handler.GetUser)
r.GET("/delete/:id", handler.DeleteUser)
r.Run()
}
func tmpResponce(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "Not Implemented",
})
}