app

package
v0.0.0-...-18492a3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Addr string
	// contains filtered or unexported fields
}

App provides high level interface to app functions for server

func NewApp

func NewApp(cfg *Config) (*App, error)

NewApp create new App instance

func (*App) Routes

func (app *App) Routes() *chi.Mux

Routes setup

func (*App) Shutdown

func (app *App) Shutdown()

Shutdown stop server

func (*App) StartServer

func (app *App) StartServer(host string, port uint16)

StartServer listen incoming requests. Blocking function

type Config

type Config struct {
	Debug        bool
	TemplatePath string
	AssetsPrefix string
	StorageSpec  string
	StatusText   string

	AdminPassword string
	UIDSecret     string // secret key to generate user ids
}

Config contains application configuration

type CreatePasteRequest

type CreatePasteRequest struct {
	Text      string `json:"text"`
	Syntax    string `json:"syntax"`
	UserToken string `json:"token,omitempty"`
	Ttl       time.Duration
}

func ParseCreatePasteRequest

func ParseCreatePasteRequest(r *http.Request) (*CreatePasteRequest, error)

type Document

type Document struct {
	render.Document
	DocID      string
	CreateTime time.Time
}

type Store

type Store interface {
	SetBlob(key string, reader io.Reader, meta map[string]string, ttl time.Duration) error
	GetBlob(key string) (io.Reader, map[string]string, error)
	DeleteBlob(key string) error
}

type UserError

type UserError struct {
	Inner   error
	UserMsg string
}

UserError error caused by wrong user input. Contains causer error and message intended to show to user

func WrapfUserError

func WrapfUserError(err error, format string, a ...interface{}) UserError

WrapfUserError return UserError with formatted user message

func (UserError) Error

func (e UserError) Error() string

func (UserError) String

func (e UserError) String() string

Jump to

Keyboard shortcuts

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