request

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthedFrom

func AuthedFrom(ctx context.Context) *model.User

func Authenticate

func Authenticate(secret []byte, users *store.Users) func(http.Handler) http.Handler

func Authorize

func Authorize(roles ...model.UserRole) func(http.Handler) http.Handler

func ExtractJwtToken

func ExtractJwtToken(r *http.Request) (string, error)

func GenerateJwtToken

func GenerateJwtToken(issuer string, expireAfter time.Duration, secret []byte, user *model.User) (string, error)

func ImageFrom

func ImageFrom(ctx context.Context) *model.Image

func JSON

func JSON(r *http.Request, v interface{}) error

func Pagination

func Pagination(pageName, sizeName string, defaultSize int64) func(http.Handler) http.Handler

func ParseJwtClaims

func ParseJwtClaims(jwtToken string, secret []byte, claims jwt.Claims) error

func PinlFrom

func PinlFrom(ctx context.Context) *model.Pinl

func PkgFrom

func PkgFrom(ctx context.Context) *model.Pkg

func QueryBool

func QueryBool(r *http.Request, paramName string) field.NullBool

func QueryCsv

func QueryCsv(r *http.Request, paramName string) []string

func ShareFrom

func ShareFrom(ctx context.Context) *model.Share

func SharetagFrom

func SharetagFrom(ctx context.Context) *model.Sharetag

func TagFrom

func TagFrom(ctx context.Context) *model.Tag

func UserFrom

func UserFrom(ctx context.Context) *model.User

func WithAuthed

func WithAuthed(ctx context.Context, user *model.User) context.Context

func WithImage

func WithImage(ctx context.Context, image *model.Image) context.Context

func WithPaginator

func WithPaginator(ctx context.Context, p *Paginator) context.Context

func WithPinl

func WithPinl(ctx context.Context, pinl *model.Pinl) context.Context

func WithPkg

func WithPkg(ctx context.Context, pkg *model.Pkg) context.Context

func WithShare

func WithShare(ctx context.Context, share *model.Share) context.Context

func WithSharetag

func WithSharetag(ctx context.Context, sharetag *model.Sharetag) context.Context

func WithTag

func WithTag(ctx context.Context, tag *model.Tag) context.Context

func WithUser

func WithUser(ctx context.Context, user *model.User) context.Context

Types

type AuthClaims

type AuthClaims struct {
	jwt.StandardClaims
	UserID string `json:"userId"`
	Hash   string `json:"hash"`
}

type ContextKey

type ContextKey int
const (
	PaginatorCtxKey ContextKey = iota
	AuthedCtxKey
	UserCtxKey
	ShareCtxKey
	PinlCtxKey
	PkgCtxKey
	TagCtxKey
	SharetagCtxKey
	ImageCtxKey
)

type Paginator

type Paginator struct {
	Page     int64
	PageSize int64
}

func NewPaginatorFromRequest

func NewPaginatorFromRequest(r *http.Request, pageName, sizeName string, defaultSize int64) (*Paginator, error)

func PaginatorFrom

func PaginatorFrom(ctx context.Context) *Paginator

func (*Paginator) ToOpts

func (p *Paginator) ToOpts() store.ListOpts

func (*Paginator) ToPageInfo

func (p *Paginator) ToPageInfo(total int64) *response.PageInfo

type PinlQuery

type PinlQuery struct {
	Query string
	IDs   []string
	Tags  []string
	NoTag field.NullBool
}

func ParsePinlQuery

func ParsePinlQuery(r *http.Request) (*PinlQuery, error)

type PkgQuery added in v0.4.1

type PkgQuery struct {
	IDs []string
}

func ParsePkgQuery added in v0.4.1

func ParsePkgQuery(r *http.Request) (*PkgQuery, error)

type StatQuery

type StatQuery struct {
	IDs       []string
	PkgIDs    []string
	Kinds     []model.StatKind
	Latest    field.NullBool
	ParentIDs []string
}

func ParseStatQuery

func ParseStatQuery(r *http.Request) (*StatQuery, error)

type TagQuery

type TagQuery struct {
	Query     string
	IDs       []string
	Names     []string
	ParentIDs []string
}

func ParseTagQuery

func ParseTagQuery(r *http.Request) (*TagQuery, error)

Jump to

Keyboard shortcuts

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