server

package
v0.0.0-...-223e126 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const UserCtxKey = "ctxUser"

Variables

View Source
var (
	ErrEmptyResumeList = errors.New("Empty resume list")

	UsersBucket     = []byte("usersv1")
	UsersKey        = []byte("list")
	MailLoginRegExp = regexp.MustCompile(`^([^@]*)`)
)
View Source
var Endpoint = oauth2.Endpoint{
	AuthURL:  "https://hh.ru/oauth/authorize",
	TokenURL: "https://hh.ru/oauth/token",
}

Endpoint is HH's OAuth 2.0 endpoint.

Functions

func SetUserToContext

func SetUserToContext(r *http.Request, user *User)

Types

type SafeUser

type SafeUser struct {
	ID string `json:"id"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(config *config.Config) *Server

func (*Server) Auth

func (s *Server) Auth(next http.HandlerFunc) http.HandlerFunc

func (*Server) AuthorizeHandler

func (s *Server) AuthorizeHandler(w http.ResponseWriter, r *http.Request)

func (*Server) CallbackHandler

func (s *Server) CallbackHandler(w http.ResponseWriter, r *http.Request)

func (*Server) Decrypt

func (s *Server) Decrypt(encrypted string, body interface{}) error

func (*Server) DeleteHandler

func (s *Server) DeleteHandler(w http.ResponseWriter, r *http.Request)

func (*Server) DumpLoop

func (s *Server) DumpLoop()

func (*Server) Encrypt

func (s *Server) Encrypt(body interface{}) (string, error)

func (*Server) Init

func (s *Server) Init() error

func (*Server) LogoutHandler

func (s *Server) LogoutHandler(w http.ResponseWriter, r *http.Request)

func (*Server) MeHandler

func (s *Server) MeHandler(w http.ResponseWriter, r *http.Request)

func (*Server) RestoreUserList

func (s *Server) RestoreUserList() error

func (*Server) SaveUserList

func (s *Server) SaveUserList() error

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop() error

func (*Server) UpdateLoop

func (s *Server) UpdateLoop()

type User

type User struct {
	ID          string        `json:"id"`
	Email       string        `json:"email"`
	Token       *oauth2.Token `json:"token"`
	UpdatedAt   time.Time     `json:"updated_at"`
	UpdateCount int           `json:"update_count"`
}

func GetUserFromContext

func GetUserFromContext(r *http.Request) *User

func (*User) SafeMail

func (u *User) SafeMail() string

func (*User) ToSafeUser

func (u *User) ToSafeUser() *User

Jump to

Keyboard shortcuts

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