这里有个巨坑 官方文档没有提及 这个需要导入v4版本的中间件
import (
"net/http"
"time"
"github.com/idoubi/goz"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
main function
func main() {
e := echo.New()
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{AllowOrigins: []string{"*"}, AllowMethods: []string{echo.GET, echo.HEAD, echo.PUT, echo.PATCH, echo.POST, echo.DELETE}}))
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
e.POST("/textserver", textserver)
e.Logger.Fatal(e.Start(":1323"))
}
Comments | NOTHING