http

package
v0.0.0-...-78a6345 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ok int = iota
	Fail
)

Variables

View Source
var (
	GetUserCtx = struct{}{}
	TokenCtx   = struct{}{}
)

Functions

This section is empty.

Types

type ErrMsg

type ErrMsg struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

func (ErrMsg) Error

func (e ErrMsg) Error() string

func (ErrMsg) String

func (e ErrMsg) String() string

type GetUserFunc

type GetUserFunc func(context context.Context)

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type MailInfo

type MailInfo struct {
	*model.VerifyCode
	Title   string
	Content string
}

type Option

type Option func(server *Server)

func WithConfigReloader

func WithConfigReloader(f func() chan configs.WebConfig) Option

func WithEmailSender

func WithEmailSender(sender mail.Sender) Option

func WithSmsSender

func WithSmsSender(sender sms.Sender) Option

func WithUploader

func WithUploader(uploader fs.Uploader) Option

type RegisterRequest

type RegisterRequest struct {
	Email    string `json:"email"`
	Mobile   string `json:"mobile"`
	Code     string `json:"code"`
	Password string `json:"password"`
	Nickname string `json:"nickname"`
	Avatar   string `json:"avatar"`
}

RegisterRequest is the params to register

type SendEmailVerifyCodeRequest

type SendEmailVerifyCodeRequest struct {
	Email string `json:"email"`
}

type SendSmsRequest

type SendSmsRequest struct {
	Mobile string `json:"mobile"`
}

SendSmsRequest send sms request.

type Server

type Server struct {
	LoginHook []func(user *model.User)
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config configs.WebConfig, options ...Option) *Server

func (*Server) GetUser

func (s *Server) GetUser(ctx context.Context) (*model.User, context.Context, error)

GetUser is a lazy func to get user from context

func (*Server) Run

func (s *Server) Run() error

func (*Server) Upload

func (s *Server) Upload(ctx *gin.Context)

Upload upload a new file

type SmsInfo

type SmsInfo struct {
	*model.VerifyCode
	Content string
}

type SuccessMsg

type SuccessMsg struct {
	Message string      `json:"message"`
	Code    int         `json:"code"`
	Data    interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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