api

package
v0.0.0-...-09e72e1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package api contains all the required methods and structs for serving mouthful requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckModerationVariables

func CheckModerationVariables(config *model.Config) error

CheckModerationVariables checks to see if the required moderation flags have been set in the config or not

func GetServer

func GetServer(db *abstraction.Database, config *model.Config) (*gin.Engine, error)

GetServer returns an instance of the mouthful server

func NormalizePath

func NormalizePath(input string) string

NormalizePath adds a missing slash at the front or the end of given input path

func ShortenAuthor

func ShortenAuthor(input string, allowedLength int) string

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

func (r *Router) CreateComment(c *gin.Context)

CreateComment creates a comment from CreateCommentBody in JSON form

func (*Router) DeleteComment

func (r *Router) DeleteComment(c *gin.Context)

DeleteComment deletes comment by given id

func (*Router) GetAdminConfig

func (r *Router) GetAdminConfig(c *gin.Context)

GetAdminConfig returns the admin config portion

func (*Router) GetAllComments

func (r *Router) GetAllComments(c *gin.Context)

GetAllComments returns an array of comments

func (*Router) GetAllThreads

func (r *Router) GetAllThreads(c *gin.Context)

GetAllThreads returns an array of threads

func (*Router) GetClientConfig

func (r *Router) GetClientConfig(c *gin.Context)

GetClientConfig returns the client config portion

func (*Router) GetComments

func (r *Router) GetComments(c *gin.Context)

GetComments returns the comments from thread that is passed as query parameter uri

func (*Router) Login

func (r *Router) Login(c *gin.Context)

Login logs the user in

func (*Router) OAuth

func (r *Router) OAuth(c *gin.Context)

OAuth initializes the OAuth flow by redirecting the user to the providers login page

func (*Router) OAuthCallback

func (r *Router) OAuthCallback(c *gin.Context)

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

func (r *Router) RestoreDeletedComment(c *gin.Context)

RestoreDeletedComment restores the deleted comment by given id

func (*Router) SetProviders

func (r *Router) SetProviders(input map[string]*provider.Provider)

SetProviders sets the OAUTH providers for the router

func (*Router) Status

func (r *Router) Status(c *gin.Context)

Status responds with 200 when asked

func (*Router) UpdateComment

func (r *Router) UpdateComment(c *gin.Context)

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

func (UnmoderatedFs) Exists

func (cfs UnmoderatedFs) Exists(prefix string, filepath string) bool

Exists determines if the file exists or not

Directories

Path Synopsis
Package model contains the model definitions for mouthful API response and request types.
Package model contains the model definitions for mouthful API response and request types.

Jump to

Keyboard shortcuts

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