api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BYTE     = 1.0
	KILOBYTE = 1024 * BYTE
	MEGABYTE = 1024 * KILOBYTE
	GIGABYTE = 1024 * MEGABYTE
	TERABYTE = 1024 * GIGABYTE
)
View Source
const (
	ChromeUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36"
)

Variables

This section is empty.

Functions

func PrintBytes

func PrintBytes(size uint64) string

PrintBytes

Types

type App

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

App

func NewApp

func NewApp(config *Config, store Store, limit Limiter, log Logger) *App

NewApp

func (*App) Capture

func (a *App) Capture(link string, width, height int64) ([]byte, error)

Capture ScreenShot

func (*App) Close

func (a *App) Close()

Close

func (*App) Sync

func (a *App) Sync()

Sync

type Config

type Config struct {
	Port  string `yaml:"port"`
	Debug bool   `yaml:"debug"`
	//
	Rate   float64 `yaml:"rate"`
	Bursts int     `yaml:"bursts"`
	//
	ImageCache time.Duration `yaml:"image_cache"`
	//
	StorePath  string `yaml:"store"`
	LogPath    string `yaml:"log"`
	ChromePath string `yaml:"chrome_data"`
}

Config

func YAMLConfig

func YAMLConfig(path string) (*Config, error)

YAMLConfig

type Image

type Image struct {
	UUID      string      `json:"uuid"`
	Status    ImageStatus `json:"status"`
	Message   string      `json:"message"`
	Binary    []byte      `json:"binary"`
	CreatedAt time.Time   `json:"created_at"`
}

Image

type ImageStatus

type ImageStatus string

ImageStatus

const (
	ImageStatusSuccess ImageStatus = "success"
	ImageStatusPending ImageStatus = "pending"
	ImageStatusFail    ImageStatus = "fail"
)

type Limiter

type Limiter interface {
	FindIPAddr(ip string) *rate.Limiter
	Clean(d time.Duration)
	Statistic() map[string]interface{}
}

Limiter

type Logger

type Logger interface {
	Info(on, message string, properties map[string]string)
	Error(on, message string, properties map[string]string)
	Fetal(on, message string, properties map[string]string)
	Close()
}

Logger

type Server

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

Server

func NewHTTPServer

func NewHTTPServer(app *App) *Server

NewHTTPServer

func (*Server) ListenAndServe

func (mux *Server) ListenAndServe(port string) error

ListenAndServe

type Store

type Store interface {
	SaveImage(img *Image) error
	FindImage(key string) (*Image, error)
	Clean(d time.Duration) error
	Statistic() (map[string]interface{}, error)
	Close()
}

Store

Jump to

Keyboard shortcuts

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