- introduces auth package, for common (sam, crm) auth handlers - routes are now generated inside server package, each handler got its own MountRoutes(r chi.Router, middlewares ...func(http.Handler) http.Handler) - there MountRoute methods are now called from non-generated code so we can inject services to (rest) controllers
27 lines
298 B
Go
27 lines
298 B
Go
package auth
|
|
|
|
type (
|
|
Identifiable interface {
|
|
GetID() uint64
|
|
Valid() bool
|
|
}
|
|
|
|
Identity struct {
|
|
id uint64
|
|
}
|
|
)
|
|
|
|
func NewIdentity(id uint64) *Identity {
|
|
return &Identity{
|
|
id: id,
|
|
}
|
|
}
|
|
|
|
func (i Identity) GetID() uint64 {
|
|
return i.id
|
|
}
|
|
|
|
func (i Identity) Valid() bool {
|
|
return i.id > 0
|
|
}
|