# README
Connect Middleware for echo
Installation
To install the package, run:
go get github.com/go-zoox/connect-middleware-for-echo
Getting Started
package main
import (
"github.com/go-zoox/connect-middleware-for-echo"
"github.com/labstack/echo/v4"
)
func main() {
r := echo.New()
r.Use(connect.Create("YOUR_SECRET_KEY"))
r.GET("/user", func(c echo.Context) error {
user, err := connect.GetUser(c)
if err != nil {
return c.JSON(401, map[string]any{
"message": "unauthorized",
})
}
return c.JSON(200, map[string]any{
"user": user,
})
})
r.GET("/", func(c echo.Context) error {
return c.JSON(200, map[string]any{
"message": "helloworld",
})
})
r.Logger.Fatal(r.Start(":8080"))
}
Related Projects
- go-zoox/connect - The Auth Connect.
- go-zoox/connect-middleware-for-zoox - The Auth Connect Middleware for Zoox.
License
GoZoox is released under the MIT License.
# Packages
No description provided by the author
# Functions
Create creates a connect middleware for gin.
GetToken get user from context.
GetUser gets the user from the context.
MustGetToken get user from context.
MustGetUser get user from context.
# Constants
ContextUserKey is the key for the user in the context.
# Variables
Version is the current version of the package.
# Structs
CreateOptions is the options for the Create middleware.