hub

package
v0.0.0-...-23e951e Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(file string, opt *Options) error

func RandNums

func RandNums(n int) []int

func SaveFile

func SaveFile(filePath string, file *os.File) error

func WithSuffixs

func WithSuffixs(fileSuffix string, suffix []string) bool

Types

type Image

type Image struct {
	Suffix    string        `json:"suffix,omitempty"`
	Name      string        `json:"name,omitempty"`
	Path      string        `json:"path,omitempty"`
	Result    string        `json:"Result,omitempty"`
	CreatedAt time.Duration `json:"created_at,omitempty"`
}

type Options

type Options struct {
	Salt      string   `yaml:"salt" json:"salt,omitempty"`
	Directory string   `yaml:"directory" json:"directory,omitempty"`
	Suffixs   []string `yaml:"suffixs" json:"suffixs,omitempty"`
	MaxSize   int32    `yaml:"max_size" json:"max_size,omitempty"`
	Domain    string   `yaml:"domain" json:"domain,omitempty"`
}

type ResultType

type ResultType int8
const (
	Markdown ResultType = iota
	HTML
	URI
)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(port int16) *Server

func (*Server) RequestMapping

func (s *Server) RequestMapping(path string, action func(w http.ResponseWriter, r *http.Request))

func (*Server) Run

func (s *Server) Run()

func (*Server) Stop

func (s *Server) Stop() error

type Storage

type Storage struct {
	*Options
	Hashed *hashids.HashID
}

func NewHub

func NewHub(opt *Options) (*Storage, error)

func (*Storage) SaveAs

func (h *Storage) SaveAs(file *os.File, tp ResultType) (*Image, error)

Jump to

Keyboard shortcuts

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