api

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2018 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppInfo

func AppInfo(app string, version string) func(http.Handler) http.Handler

AppInfo adds custom app-info to the response header

func Logger

func Logger(ipFn func(ip string) string, flags ...LoggerFlag) func(http.Handler) http.Handler

Logger middleware prints http log. Customized by set of LoggerFlag

func Ping

func Ping(next http.Handler) http.Handler

Ping middleware response with pong to /ping. Stops chain if ping request detected

func Recoverer

func Recoverer(next http.Handler) http.Handler

Recoverer is a middleware that recovers from panics, logs the panic and returns a HTTP 500 status if possible.

Types

type JSON

type JSON map[string]interface{}

JSON is a map alias, just for convenience

type LoggerFlag

type LoggerFlag int

LoggerFlag type

const (
	LogAll LoggerFlag = iota
	LogUser
	LogBody
	LogNone
)

logger flags enum

type Migrator

type Migrator struct {
	Version        string
	Cache          cache.LoadingCache
	NativeImporter migrator.Importer
	DisqusImporter migrator.Importer
	NativeExported migrator.Exporter
	SecretKey      string
	// contains filtered or unexported fields
}

Migrator rest runs on unexposed port and available for local requests only

func (*Migrator) Run

func (m *Migrator) Run(port int)

Run the listener and request's router, activate rest server this server doesn't have any authentication and SHOULDN'T BE EXPOSED in any way

func (*Migrator) Shutdown

func (m *Migrator) Shutdown()

Shutdown import http server

type Rest

type Rest struct {
	Version         string
	DataService     *service.DataStore
	Authenticator   auth.Authenticator
	Exporter        migrator.Exporter
	Cache           cache.LoadingCache
	AvatarProxy     *proxy.Avatar
	ImageProxy      *proxy.Image
	WebRoot         string
	RemarkURL       string
	ReadOnlyAge     int
	ScoreThresholds struct {
		Low      int
		Critical int
	}
	// contains filtered or unexported fields
}

Rest is a rest access server

func (*Rest) Run

func (s *Rest) Run(port int)

Run the lister and request's router, activate rest server

func (*Rest) Shutdown

func (s *Rest) Shutdown()

Shutdown rest http server

Jump to

Keyboard shortcuts

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