Documentation
¶
Index ¶
- Constants
- Variables
- func AccountIDFromCtx(ctx context.Context) (uuid.UUID, bool)
- func CheckPasswordHash(password []byte, passwordHash string) (bool, error)
- func CtxWithAccountID(parent context.Context, accountID uuid.UUID) context.Context
- func CtxWithID(parent context.Context, id uuid.UUID) context.Context
- func CtxWithSessionID(parent context.Context, accountID uuid.UUID) context.Context
- func IDFromCtx(ctx context.Context) (uuid.UUID, bool)
- func JSONError(rw http.ResponseWriter, r *http.Request, msg string, code int)
- func NewPasswordHash(password, salt []byte) string
- func RequireRequestBody(next http.Handler) http.Handler
- func SessionIDFromCtx(ctx context.Context) (uuid.UUID, bool)
- func WithUUIDFromURL(next http.Handler) http.Handler
- type AccountGetResponse
- type AccountPutRequest
- type AccountPutResponse
- type FilePutResponse
- type HTTPError
- type JSONResponse
- type PostDeleteResponse
- type PostGetResponse
- type PostPostRequest
- type PostPostResponse
- type PostPutRequest
- type PostPutResponse
- type ProfileGetResponse
- type ProfilePutRequest
- type ProfilePutResponse
- type Server
- func (server *Server) APIv1Router(r chi.Router)
- func (server *Server) AccountGet(rw http.ResponseWriter, r *http.Request)
- func (server *Server) AccountHead(rw http.ResponseWriter, r *http.Request)
- func (server *Server) AccountPut(rw http.ResponseWriter, r *http.Request)
- func (server *Server) AutoCleanupExpiredSessions(every time.Duration)
- func (server *Server) Close()
- func (server *Server) FilePut(rw http.ResponseWriter, r *http.Request)
- func (server *Server) GetMigrationStatus(ctx context.Context) (applied, unapplied int, err error)
- func (server *Server) Migrate(ctx context.Context) (applied int, err error)
- func (server *Server) PostDelete(rw http.ResponseWriter, r *http.Request)
- func (server *Server) PostGet(rw http.ResponseWriter, r *http.Request)
- func (server *Server) PostPost(rw http.ResponseWriter, r *http.Request)
- func (server *Server) PostPut(rw http.ResponseWriter, r *http.Request)
- func (server *Server) ProfileGet(rw http.ResponseWriter, r *http.Request)
- func (server *Server) ProfileHead(rw http.ResponseWriter, r *http.Request)
- func (server *Server) ProfilePut(rw http.ResponseWriter, r *http.Request)
- func (server *Server) SessionDelete(rw http.ResponseWriter, r *http.Request)
- func (server *Server) SessionPut(rw http.ResponseWriter, r *http.Request)
- func (server *Server) SetLocalInstance(create bool) (created bool, err error)
- func (server *Server) Setup(create bool) error
- func (server *Server) StartScheduler() error
- func (server *Server) Transaction(fn func(ctx context.Context, tx bun.Tx) error) error
- func (server *Server) ValidateSession(next http.Handler) http.Handler
- func (server *Server) View(fn func(ctx context.Context, tx bun.Tx) error) error
- type SessionPutRequest
- type SessionPutResponse
Constants ¶
View Source
const ( Argon2Memory = 64 * 1024 Argon2Time = 2 Argon2Threads = 4 Argon2KeyLength = 32 )
Variables ¶
View Source
var JSONResponseOK = JSONResponse{Status: "ok"}
Functions ¶
func CtxWithAccountID ¶
func CtxWithSessionID ¶
func NewPasswordHash ¶
Types ¶
type AccountGetResponse ¶
type AccountGetResponse struct {
JSONResponse
Account models.Account `json:"account"`
}
type AccountPutRequest ¶
type AccountPutResponse ¶
type AccountPutResponse struct {
JSONResponse
Account models.Account `json:"account"`
}
type FilePutResponse ¶
type FilePutResponse struct {
JSONResponse
Files []*models.File
}
type JSONResponse ¶
type PostDeleteResponse ¶
type PostDeleteResponse struct {
JSONResponse
}
type PostGetResponse ¶
type PostGetResponse struct {
JSONResponse
Post models.Post `json:"post"`
}
type PostPostRequest ¶
type PostPostResponse ¶
type PostPostResponse struct {
JSONResponse
Post models.Post `json:"post"`
}
type PostPutRequest ¶
type PostPutRequest struct {
ProfileID uuid.UUID `json:"profile_id"`
ReplyToID *uuid.UUID `json:"reply_to_id"`
Subject *string `json:"subject"`
Content string `json:"content"`
Tags []string `json:"tags"`
PollID *uuid.UUID `json:"poll_id"`
GroupIDs []uuid.UUID `json:"group_ids"`
FileIDs []uuid.UUID `json:"file_ids"`
PublishAt *time.Time `json:"publish_at"`
DeleteAt *time.Time `json:"delete_at"`
}
type PostPutResponse ¶
type ProfileGetResponse ¶
type ProfileGetResponse struct {
JSONResponse
Profile models.Profile `json:"profile"`
}
type ProfilePutRequest ¶
type ProfilePutResponse ¶
type ProfilePutResponse struct {
JSONResponse
Profile models.Profile `json:"profile"`
}
type Server ¶
func (*Server) APIv1Router ¶
func (*Server) AccountGet ¶
func (server *Server) AccountGet(rw http.ResponseWriter, r *http.Request)
func (*Server) AccountHead ¶
func (server *Server) AccountHead(rw http.ResponseWriter, r *http.Request)
func (*Server) AccountPut ¶
func (server *Server) AccountPut(rw http.ResponseWriter, r *http.Request)
func (*Server) AutoCleanupExpiredSessions ¶
func (*Server) GetMigrationStatus ¶
func (*Server) PostDelete ¶
func (server *Server) PostDelete(rw http.ResponseWriter, r *http.Request)
func (*Server) ProfileGet ¶
func (server *Server) ProfileGet(rw http.ResponseWriter, r *http.Request)
func (*Server) ProfileHead ¶
func (server *Server) ProfileHead(rw http.ResponseWriter, r *http.Request)
func (*Server) ProfilePut ¶
func (server *Server) ProfilePut(rw http.ResponseWriter, r *http.Request)
func (*Server) SessionDelete ¶
func (server *Server) SessionDelete(rw http.ResponseWriter, r *http.Request)
func (*Server) SessionPut ¶
func (server *Server) SessionPut(rw http.ResponseWriter, r *http.Request)
func (*Server) SetLocalInstance ¶
func (*Server) StartScheduler ¶
func (*Server) Transaction ¶
func (*Server) ValidateSession ¶
type SessionPutRequest ¶
type SessionPutResponse ¶
type SessionPutResponse struct {
JSONResponse
Session models.AccountSession `json:"session"`
Token string `json:"token"`
}
Click to show internal directories.
Click to hide internal directories.