From httprouter to echo.
- [x] Get list to work
- [x] Get creation to work
- [x] Get delete to work
- [x] Modify endpoint subgenerator
- [x] Get http/2 to work
- [x] Clean up
Go is not serving static files - Switch web framework
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
9条回答 默认 最新
weixin_39732866 2020-11-19 11:28关注In echo, it's much more straight forward:
go package main import ( "fmt" "net/http" "github.com/labstack/echo" "github.com/labstack/echo/engine/fasthttp" "github.com/labstack/echo/middleware" ) type U struct { N string `json:"name"` } func main() { port := ":3000" fmt.Println(port) e := echo.New() e.Use(middleware.Static("")) e.Use(middleware.Static("client/dev")) e.Get("/api", func(c echo.Context) error { u := U{N: "abcdef"} return c.JSON(http.StatusOK, u) }) e.Run(fasthttp.New(port)) }I'll create a branch today to get this fixed.
解决 无用评论 打赏 举报