https://github.com/mhewedy/echox
Extensions for echo the golang web framework
https://github.com/mhewedy/echox
echo-framework go golang golang-library
Last synced: 10 months ago
JSON representation
Extensions for echo the golang web framework
- Host: GitHub
- URL: https://github.com/mhewedy/echox
- Owner: mhewedy
- Created: 2019-08-15T17:02:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-17T02:11:11.000Z (over 6 years ago)
- Last Synced: 2025-02-06T12:12:54.643Z (12 months ago)
- Topics: echo-framework, go, golang, golang-library
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Set of Extensios for echo framework
[](https://godoc.org/github.com/mhewedy/echox)
[](https://goreportcard.com/report/github.com/mhewedy/echox)
### `GormAduit` middleware
It associate current user (if exits from JWT token) with current db refernce so when you save an entity, the `CreatedBy`, `UpdatedBy` columns got populated.
```go
// First your entity should embed audited.AuditedModel:
type Product struct {
gorm.Model
audited.AuditedModel
code string
}
// defines the middleware rerferencing the *gorm.DB instance
e.Use(middlewarex.GormAudit(db))
// Then get gorm db reference in the handler method via:
db := middlewarex.GetGormDB(context) // context is of type echo.Context
// use the db reference to save your entity instances.
```
### `HasRole` middleware
```go
// HasRole middleware, depends on registration of middleware.JWT
e.POST("/create-product", createProduct, middlewarex.HasRole("admin"))
```