Add: Ping router

pull/247/head
HFO4 5 years ago
parent 86896aedd0
commit 74b5bf24a8

@ -1,3 +1,5 @@
module Backend-V3
module Cloudreve
go 1.12
require github.com/gin-gonic/gin v1.4.0

@ -1,7 +1,13 @@
package main
import "fmt"
import (
"Cloudreve/routers"
)
func main() {
fmt.Println("test")
api := routers.InitRouter()
api.Run(":5000")
}

@ -0,0 +1,14 @@
package controllers
import (
"Cloudreve/serializer"
"github.com/gin-gonic/gin"
)
// Ping 状态检查页面
func Ping(c *gin.Context) {
c.JSON(200, serializer.Response{
Code: 0,
Msg: "Pong",
})
}

@ -0,0 +1,18 @@
package routers
import (
"Cloudreve/routers/controllers"
"github.com/gin-gonic/gin"
)
func InitRouter() *gin.Engine {
r := gin.Default()
// 路由
v3 := r.Group("/Api/V3")
{
v3.GET("Ping", controllers.Ping)
}
return r
}

@ -0,0 +1,9 @@
package serializer
// Response 基础序列化器
type Response struct {
Code int `json:"code"`
Data interface{} `json:"data,omitempty"`
Msg string `json:"msg"`
Error string `json:"error,omitempty"`
}
Loading…
Cancel
Save