interfaces

package
v0.0.0-...-412dc8c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2021 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App interface {
	Config() AppConfig
	Dao() AppDaos
	DB() *gorm.DB
	Logger() *zap.Logger
	Service() AppServices
	Router() *mux.Router
	RootLogger() *zap.Logger
}

type AppConfig

type AppConfig interface {
	AutoMigrate() bool
	Env() string
	Listen() ListenConfig
	MySQL() MySQLConfig
}

type AppDaos

type AppDaos interface {
	Users() UserDao
}

type AppServices

type AppServices interface {
	Login() LoginService
	JWT() JWTService
}

type JWTGenerateResult

type JWTGenerateResult interface {
	SignedToken() string
	Token() jwt.Token
	Claims() auth.JWTClaims
}

type JWTService

type JWTService interface {
	// Generate Create and sign a token for a given user.
	Generate(user *models.User) (JWTGenerateResult, error)
	// Validate Securely validate a token string, returning the relevant parsed JWT data.
	//
	// If JWTValidateResult is nil, validation has failed for the token. If err is not nil,
	Validate(token string) (JWTValidateResult, error)
}

type JWTValidateResult

type JWTValidateResult interface {
	Token() jwt.Token
	Claims() auth.JWTClaims
}

type ListenConfig

type ListenConfig interface {
	Host() string
	Port() uint16
}

type LoginResult

type LoginResult interface {
	User() models.User
	SignedToken() string
	Token() jwt.Token
	Claims() auth.JWTClaims
}

type LoginService

type LoginService interface {
	Login(email, password string) (*LoginResult, error)
}

type MySQLConfig

type MySQLConfig interface {
	Host() string
	Port() uint16
	Database() string
	User() string
	Password() string
}

type RequestContext

type RequestContext interface {
	// ID The unique request ID as an UUID.
	ID() uuid.UUID
	// App The top-level application instance, which provides access to application services and configuration.
	App() App
	// Config Read application-level configuration.
	Config() AppConfig
	// Services Access the different services available to the application.
	Services() AppServices
	// Dao Access the different data-access-objects available to the application.
	Dao() AppDaos
	// Logger The unique, per-handler logger for the request.
	Logger() *zap.Logger
	// Req The raw http.Request object.
	Req() *http.Request
	// Context The request context.
	Context() context.Context
	// Authenticated Whether the current request has valid auth data.
	Authenticated() bool
	// IsUser Whether the current request is authorized for user access.
	IsUser() bool
	// IsAdmin Whether the current request is authorized for admin access.
	IsAdmin() bool
	// Token Return the JWT token if the current request has a valid one.
	Token() *jwt.Token
	// Claims Return the JWT claims if the current request has valid JWT.
	Claims() *auth.JWTClaims
	// JSON Unmarshal the JSON request body.
	JSON(dest interface{}) error
	// JSONV Unmarshal the JSON request body and run validator.Validate on it.
	JSONV(dest interface{}) error
}

type UserDao

type UserDao interface {
	Get(id uint) (*models.User, error)
	Exists(id uint) (bool, error)
	WithEmail(username string) (*models.User, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL