api

package
v0.0.0-...-df34f37 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthMissing                = fmt.Errorf("missing authentication to endpoint even though it's required")
	ErrAuthFailed                 = fmt.Errorf("invalid authentication parameters")
	ErrInvalidBody                = fmt.Errorf("invalid request body")
	ErrNotFound                   = fmt.Errorf("resource was not found")
	ErrEmptyResponse              = fmt.Errorf("empty response")
	ErrTooBigBody                 = fmt.Errorf("request body too big")
	ErrPasswordRequirementsNotMet = fmt.Errorf("password has to be between 8 and 32 charecters long")
	ErrUsernameRequirementsNotMet = fmt.Errorf("username has to be between 4 and 16 charecters long")
)

Functions

func BindBodyToStruct

func BindBodyToStruct[T any](ctx *gin.Context, verifyStruct ...func(T) error) (T, error)

func SetErrResponse

func SetErrResponse(ctx *gin.Context, err error)

SetErrResponse helper for providing standard error messages in return

Types

type Configuration

type Configuration struct {
	MaxEncryptableFileSize uint64
	MaxSingleUploadSize    uint64
	MaxUploadSizePerDay    uint64
	UploadsDir             string
	UseSecureCookie        bool
	APIDomain              string
	CookieSaveTime         int
	FilePersistDuration    time.Duration
}

type Limits

type Limits struct {
	Requests int16         // Requests to allow
	Time     time.Duration // Time to next reset in seconds
}

Limits-struct is primarily used to configure the ratelimiting functionality

type Ratelimits

type Ratelimits struct {
	StrictLimit Limits
	QueryLimit  Limits
}

type Server

type Server struct {
	GinEngine  *gin.Engine
	DB         *db.Queries
	Config     *Configuration
	EncKeySize uint32
}

func NewServer

func NewServer(eng *gin.Engine, conn *db.Queries, apic *Configuration, encs uint32) *Server

func (*Server) GetRouter

func (s *Server) GetRouter() *gin.Engine

func (*Server) IncludeServerContextWorker

func (s *Server) IncludeServerContextWorker(w workers.Worker)

func (*Server) NotFoundHandler

func (s *Server) NotFoundHandler(ctx *gin.Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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