Documentation ¶
Overview ¶
Package api contains all the required methods and structs for serving mouthful requests.
Index ¶
- func CheckModerationVariables(config *model.Config) error
- func GetServer(db *abstraction.Database, config *model.Config) (*gin.Engine, error)
- func NormalizePath(input string) string
- func ShortenAuthor(input string, allowedLength int) string
- type Router
- func (r *Router) CreateComment(c *gin.Context)
- func (r *Router) DeleteComment(c *gin.Context)
- func (r *Router) GetAdminConfig(c *gin.Context)
- func (r *Router) GetAllComments(c *gin.Context)
- func (r *Router) GetAllThreads(c *gin.Context)
- func (r *Router) GetClientConfig(c *gin.Context)
- func (r *Router) GetComments(c *gin.Context)
- func (r *Router) Login(c *gin.Context)
- func (r *Router) OAuth(c *gin.Context)
- func (r *Router) OAuthCallback(c *gin.Context)
- func (r *Router) RestoreDeletedComment(c *gin.Context)
- func (r *Router) SetProviders(input map[string]*provider.Provider)
- func (r *Router) Status(c *gin.Context)
- func (r *Router) UpdateComment(c *gin.Context)
- type UnmoderatedFs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckModerationVariables ¶
CheckModerationVariables checks to see if the required moderation flags have been set in the config or not
func NormalizePath ¶
NormalizePath adds a missing slash at the front or the end of given input path
func ShortenAuthor ¶
ShortenAuthor shortens the author name to an acceptable lenght, suffixing it with ...
Types ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router handles all the different routes as well as stores our config and db objects
func New ¶
func New(db *abstraction.Database, config *configModel.Config, cache *cache.Cache) *Router
New returns a new instance of router
func (*Router) CreateComment ¶
CreateComment creates a comment from CreateCommentBody in JSON form
func (*Router) DeleteComment ¶
DeleteComment deletes comment by given id
func (*Router) GetAdminConfig ¶
GetAdminConfig returns the admin config portion
func (*Router) GetAllComments ¶
GetAllComments returns an array of comments
func (*Router) GetAllThreads ¶
GetAllThreads returns an array of threads
func (*Router) GetClientConfig ¶
GetClientConfig returns the client config portion
func (*Router) GetComments ¶
GetComments returns the comments from thread that is passed as query parameter uri
func (*Router) OAuth ¶
OAuth initializes the OAuth flow by redirecting the user to the providers login page
func (*Router) OAuthCallback ¶
OAuthCallback handles the oauth callback which finishes the auth procedure. It checks for the admin flag for the user, and if found it will set the user as admin for the rest of the session
func (*Router) RestoreDeletedComment ¶
RestoreDeletedComment restores the deleted comment by given id
func (*Router) SetProviders ¶
SetProviders sets the OAUTH providers for the router
func (*Router) UpdateComment ¶
UpdateComment updates the provided comment in body
type UnmoderatedFs ¶
type UnmoderatedFs struct {
http.FileSystem
}
UnmoderatedFs a file system we use to serve only the client.js