Echo
The echo v4 router is supported by Gleece's routes generator.
Set Router Engine
In the Gleece configuration (usually gleece.config.json
), set the routesConfig->engine
to echo
.
Configure Security Function
In the Gleece configuration, set the full package path in routesConfig->authorizationConfig->authFileFullPackageName
(e.g., github.com/gopher-fleece/gleece/security
).
Generate Routes File
Gleece CLI will generate a routes file from your annotated controllers. The output file path is specified in the routesConfig->outputPath
property of your Gleece configuration file.
Import and Register Routes
In your main.go
file, import the generated routes file and call the RegisterRoutes
function to register the routes with the Echo
router instance.
Routing Example
package main
import (
"github.com/labstack/echo/v4"
"<package>/routes" // Import the generated routes file
)
func main() {
// Create a Echo router
e := echo.New()
// Register Gleece routes
routes.RegisterRoutes(e)
// Start the server
e.Start(":8080")
}
Authentication Function
package security
import (
"github.com/gopher-fleece/runtime"
"github.com/labstack/echo/v4"
)
func GleeceRequestAuthorization(ctx echo.Context, check runtime.SecurityCheck) *runtime.SecurityError {
return nil
}