server.go 714 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package web
  2. import (
  3. "git.sfnt.net/sfnt/cnlink/lib"
  4. "git.sfnt.net/sfnt/cnlink/web/api"
  5. "github.com/gin-gonic/gin"
  6. )
  7. func Start() {
  8. r := gin.Default()
  9. //r.LoadHTMLGlob("views/*")
  10. r.LoadHTMLGlob("views/**/*")
  11. r.GET("/", func(c *gin.Context) {
  12. c.JSON(200, gin.H{
  13. "message": "home page",
  14. })
  15. })
  16. r.GET("/ver", api.CheckVersion)
  17. r.GET("/health", api.CheckHealth)
  18. /*
  19. r.GET("/create", func(c *gin.Context) {
  20. c.JSON(200, gin.H{
  21. "message": "create page",
  22. })
  23. })
  24. */
  25. r.GET("/u:sid", func(c *gin.Context) {
  26. sid := c.Params.ByName("sid")
  27. //intSid,_ := strconv.ParseUint(sid,10,64)
  28. c.JSON(200, gin.H{
  29. "message": lib.String2Int(sid),
  30. })
  31. //c.Redirect(http.StatusFound,"")
  32. })
  33. r.Run()
  34. }