Documentation ¶
Index ¶
- Variables
- func Base32String(p []byte) string
- func ConvertStormError(err error) error
- func CurrentTime(next http.Handler) http.Handler
- func DefaultTokenGenerator() string
- func HTTPError(w http.ResponseWriter, code int)
- func JsonRequest(r *http.Request, p interface{}) error
- func JsonResponse(w http.ResponseWriter, ctx context.Context, p interface{})
- func Logger(logger zerolog.Logger) func(http.Handler) http.Handler
- func MustJsonMarshalToBuffer(t *testing.T, p interface{}) *bytes.Buffer
- func NewToken(n int) []byte
- func RunCase(t *testing.T, label interface{}, f func(t *testing.T))
- func UseBadger(ctx context.Context) *badger.DB
- func UseLogger(ctx context.Context) *zerolog.Logger
- func UseStorm(ctx context.Context) *storm.DB
- func UseTime(ctx context.Context) time.Time
- func Validate(p interface{}) error
- func ValidateQuery(p interface{}, v url.Values) error
- func WithBadger(ctx context.Context, db *badger.DB) context.Context
- func WithDriverTokenGenerator(ctx context.Context, gen TokenGenerator) context.Context
- func WithStorm(ctx context.Context, db *storm.DB) context.Context
- func WithTime(ctx context.Context, t time.Time) context.Context
- type Adaptor
- type AppContextKey
- type CustomValidator
- type Middleware
- type TokenGenerator
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAlreadyExists = errors.New("already exists") ErrNotFound = errors.New("not found") ErrForbidden = errors.New("forbidden") ErrUnknown = errors.New("unknown error") )
View Source
var ( ErrJsonContentType = errors.New("Content-Type is not application/json") ErrJsonHTTPMethod = errors.New("HTTP method does not have a body") )
View Source
var (
ErrSchemaDecode = errors.New("failed to decode values")
)
Functions ¶
func Base32String ¶
func ConvertStormError ¶
func DefaultTokenGenerator ¶
func DefaultTokenGenerator() string
func HTTPError ¶
func HTTPError(w http.ResponseWriter, code int)
func JsonRequest ¶
func JsonResponse ¶
func JsonResponse(w http.ResponseWriter, ctx context.Context, p interface{})
func MustJsonMarshalToBuffer ¶
func Validate ¶
func Validate(p interface{}) error
Validate validates an object using the global validator.
func ValidateQuery ¶
ValidateQuery decodes and validates an object from query values using the global decoder and validator.
func WithDriverTokenGenerator ¶
func WithDriverTokenGenerator(ctx context.Context, gen TokenGenerator) context.Context
Types ¶
type AppContextKey ¶
type AppContextKey string
const BadgerContextKey AppContextKey = "badger"
const DriverTokenGeneratorContextKey AppContextKey = "driver_token_generator"
const StormContextKey AppContextKey = "storm"
var TimeContextKey AppContextKey = "time"
type CustomValidator ¶
type CustomValidator interface {
Validate() error
}
type Middleware ¶
func Badger ¶
func Badger(db *badger.DB) Middleware
func DriverTokenGenerator ¶
func DriverTokenGenerator(gen TokenGenerator) Middleware
func Storm ¶
func Storm(path string, opts ...func(*storm.Options) error) Middleware
type TokenGenerator ¶
type TokenGenerator func() string
func UseDriverTokenGenerator ¶
func UseDriverTokenGenerator(ctx context.Context) TokenGenerator
type ValidationError ¶
type ValidationError []validator.FieldError
func (ValidationError) Error ¶
func (err ValidationError) Error() string
Click to show internal directories.
Click to hide internal directories.