/
server.go
51 lines (48 loc) · 1.34 KB
/
server.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
43
44
45
46
47
48
49
50
51
package main
import (
//"fmt"
"github.com/gin-gonic/gin"
"github.com/mikeshimura/dbflute/df"
"github.com/mikeshimura/dbflute/log"
"godbfexam/util"
"godbfexam/web"
"os"
"strings"
)
func main() {
df.DISP_SQL_DEFAULT_TIMESTAMP_FORMAT = "2006/01/02 15:04:05"
df.DISP_SQL_DEFAULT_DATE_FORMAT = "2006/01/02"
log.SetCharCode("utf-8")
url := os.Getenv("DATABASE_URL")
if strings.Contains(url, "localhost") {
util.Sslmode = "disable"
log.DebugConv("main","Sslmode:disable")
} else {
util.Sslmode = "require"
log.DebugConv("main","Sslmode:require")
}
r := gin.Default()
r.GET("/", web.IndexHtml)
r.GET("/user", web.UserHtml)
r.GET("/usertbl", web.UserTblHtml)
r.GET("/systbl", web.SysTblHtml)
r.GET("/employee", web.EmployeeHtml)
r.GET("/login", web.LoginHtml)
r.GET("/customer", web.CustomerHtml)
r.GET("/customert", web.CustomertHtml)
r.GET("/customerin", web.CustomerinHtml)
r.GET("/testtable", web.TestTableHtml)
ajax := r.Group("/ajax")
{
ajax.POST("/loginauth", web.Loginauth)
ajax.POST("/logout", web.Logout)
ajax.POST("/login", web.LoginExec)
ajax.POST("/usertbl", web.UserTableExec)
ajax.POST("/systbl", web.SysTableExec)
ajax.POST("/employee", web.EmployeeExec)
ajax.POST("/customer", web.CustomerExec)
ajax.POST("/testtable", web.TestTableExec)
}
r.Static("/static", "./static")
r.Run(":" + os.Getenv("PORT"))
}