common

package
v0.0.0-...-50d6f49 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleErr

func HandleErr(err error, ctx *gin.Context) bool

func HasAnyPrefix

func HasAnyPrefix(s string, prefixes ...string) bool

func HasAnySuffix

func HasAnySuffix(s string, suffixes ...string) bool

func RandomString

func RandomString(n int) string

func TrimPrefixesRecursive

func TrimPrefixesRecursive(s string, prefixes ...string) (r string)

Types

type Configuration

type Configuration struct {
	Webserver struct {
		Address          string `yaml:"address"`
		Port             int    `yaml:"port"`
		BaseURL          string `yaml:"base-url"`
		NotFoundRedirect string `yaml:"not-found-redirect"`
	} `yaml:"web-server"`
	Features struct {
		EnableRedirector bool `yaml:"enable-redirector"`
		EnableImages     bool `yaml:"enable-images"`
		EnableText       bool `yaml:"enable-text"`
		EnableFiles      bool `yaml:"enable-files"`
		API              struct {
			EnableAPI       bool   `yaml:"enable-api"`
			EnableAuth      bool   `yaml:"enable-auth"`
			AuthToken       string `yaml:"auth-token"`
			ManageRedirects bool   `yaml:"manage-redirects"`
			ManageImages    bool   `yaml:"manage-images"`
			ManageText      bool   `yaml:"manage-text"`
			ManageFiles     bool   `yaml:"manage-files"`
		} `yaml:"api"`
		Extra struct {
			CompressImages bool `yaml:"compress-images"`
			UseRawImageURL bool `yaml:"use-raw-image-url"`
		} `yaml:"extra"`
	} `yaml:"features"`
	Pages struct {
		PageTitles struct {
			TextTitle  string `yaml:"text-title"`
			ImageTitle string `yaml:"image-title"`
		} `yaml:"page-titles"`
	} `yaml:"pages"`
	MongoDB struct {
		URI        string `yaml:"uri"`
		Host       string `yaml:"host"`
		Port       int    `yaml:"port"`
		UseSRV     bool   `yaml:"use-srv"`
		User       string `yaml:"user"`
		Pass       string `yaml:"pass"`
		AuthSource string `yaml:"auth-source"`
		UseAuth    bool   `yaml:"use-auth"`
		DB         string `yaml:"db"`
	} `yaml:"mongodb"`
}

func LoadConfiguration

func LoadConfiguration(fileLocation string) (conf *Configuration, err error)

func (*Configuration) GetURI

func (conf *Configuration) GetURI() string

func (*Configuration) GetWebserverAddress

func (conf *Configuration) GetWebserverAddress() string

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"error"`
	Code    int    `json:"code"`
}

type Image

type Image struct {
	Identifier   string `json:"identifier"`
	FileLocation string `json:"file_location"`
	DeletionKey  string `json:"deletion_key"`
	CreationDate string `json:"creation_date"`
	FileSize     int64  `json:"file_size"`
	Views        int    `json:"views"`
}

type ImageCreated

type ImageCreated struct {
	LocationURL string `json:"location_url"`
	FileSize    int64  `json:"file_size"`
	DeletionURL string `json:"deletion_url"`
}

type Redirect

type Redirect struct {
	Identifier   string `json:"identifier"`
	Location     string `json:"location"`
	DeletionKey  string `json:"deletion_key"`
	CreationDate string `json:"creation_date"`
	Clicks       int    `json:"clicks"`
}

type RedirectCreated

type RedirectCreated struct {
	ShortenedURL string `json:"shortened_url"`
	TargetURL    string `json:"target_url"`
	DeletionURL  string `json:"deletion_url"`
}

type Text

type Text struct {
	Identifier   string `json:"identifier"`
	Content      string `json:"content"`
	Preview      string `json:"preview"`
	DeletionKey  string `json:"deletion_key"`
	CreationDate string `json:"creation_date"`
	Views        int    `json:"views"`
}

type TextCreated

type TextCreated struct {
	LocationURL string `json:"location_url"`
	Content     string `json:"content"`
	DeletionURL string `json:"deletion_url"`
}

Jump to

Keyboard shortcuts

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