Compare commits

...

3 Commits

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1 @@
main.go

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/for_you.iml" filepath="$PROJECT_DIR$/.idea/for_you.iml" />
</modules>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

Binary file not shown.

@ -0,0 +1,24 @@
package pkg
import (
"github.com/gin-gonic/gin"
)
type Gin struct {
C *gin.Context
}
type Response struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
func (g *Gin) Response(httpCode int, errMsg string, data interface{}) {
g.C.JSON(httpCode, Response{
Code: httpCode,
Msg: errMsg,
Data: data,
})
return
}

@ -0,0 +1,21 @@
package routers
import (
"github.com/gin-gonic/gin"
"net/http"
api "webserver/pkg/api"
)
// InitRouter 初始化路由信息
func InitRouter() *gin.Engine {
r := gin.Default()
// 静态文件路由
r.LoadHTMLGlob("./template/*")
r.StaticFS("/template", http.Dir("template"))
r.StaticFS("/static", http.Dir("static"))
r.GET("/trans", api.SqliteQueryTRANSLATION)
r.GET("/xyz", api.SqliteQueryXYZ)
r.GET("/address", api.SendAddress)
r.GET("/request", api.Request)
return r
}
Loading…
Cancel
Save