initRouter.go 401 B

12345678910111213141516171819202122
  1. package initialize
  2. import (
  3. "dhcp/api"
  4. "github.com/gin-gonic/gin"
  5. "net/http"
  6. )
  7. func InitRouter() *gin.Engine {
  8. r := gin.Default()
  9. // 处理根路径
  10. r.GET("/", func(ctx *gin.Context) {
  11. ctx.HTML(http.StatusOK, "index.html", nil)
  12. })
  13. // 处理其它所有路径
  14. r.NoRoute(func(ctx *gin.Context) {
  15. ctx.HTML(http.StatusOK, "index.html", nil)
  16. })
  17. api.DHCPServerRegisterRoute(r)
  18. return r
  19. }