Documentation ¶
Overview ¶
Package service handles all business logic with the models
Index ¶
- Constants
- Variables
- func CreatePost(auth Authorizator, s store.Store, user *model.User, data *CreatePostData) (*model.Post, error)
- func ExtractToken(headerValue string) (string, error)
- func GenerateStorageID() string
- type Authenticator
- type Authorizator
- type CreatePostData
- type CreatePostMediaData
- type FilesystemStorage
- type PostingError
- type Storage
- type UserGetter
Constants ¶
const Default = "default"
Default role
Variables ¶
Functions ¶
func CreatePost ¶
func CreatePost(auth Authorizator, s store.Store, user *model.User, data *CreatePostData) (*model.Post, error)
CreatePost creates a new post
func ExtractToken ¶
ExtractToken extracts a token from it's bearer prefix and returns it's raw value. Returns an error if no valid token is found
Types ¶
type Authenticator ¶
type Authenticator interface { // AuthenticateToken authenticates a token and returns it's user AuthenticateToken(tokenString string) (*model.User, error) // CreateToken creates a new JWT token CreateToken(user *model.User) (string, error) }
Authenticator handles all authentication roles
func NewAuthenticator ¶
func NewAuthenticator(users UserGetter, secret []byte) Authenticator
NewAuthenticator creates a new Authenticator using the default implementation.
type Authorizator ¶
Authorizator determines if a user can perform an action or not
func NewAuthorizator ¶
func NewAuthorizator(roles map[string][]string, inheritance map[string][]string) Authorizator
NewAuthorizator creates a new Authorizator
func NewAuthorizatorFromFile ¶
func NewAuthorizatorFromFile(f io.Reader) (Authorizator, error)
NewAuthorizatorFromFile creates a new authorizator reading content from an existing permission file
type CreatePostData ¶
type CreatePostData struct { Parent string `form:"parent"` Board string `form:"board"` Name string `form:"name"` Comment string `form:"comment"` Subject string `form:"subject"` User *model.User Medias []*CreatePostMediaData IP string }
CreatePostRequest constains all post creation information necessary for the creation of a new post
type CreatePostMediaData ¶
CreatePostMediaRequest contains all media information for upload
type FilesystemStorage ¶
type FilesystemStorage struct {
// contains filtered or unexported fields
}
FilesystemStorage stores medias in the filesystem
func NewFilesystemStorage ¶
func NewFilesystemStorage(path string) *FilesystemStorage
NewFilesystemStorage creates a new filesystem storage
func (*FilesystemStorage) Delete ¶
func (s *FilesystemStorage) Delete(id string) error
Delete deletes a filesystem file by it's id
type PostingError ¶
type PostingError struct {
// contains filtered or unexported fields
}
func (*PostingError) Error ¶
func (p *PostingError) Error() string