api

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 47 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// None defines to run http server only
	None sslMode = iota

	// Static defines to run both https and http server. Redirect http to https
	Static

	// Auto defines to run both https and http server. Redirect http to https. Https server with autocert support
	Auto
)

Variables

This section is empty.

Functions

func URLKey

func URLKey(r *http.Request) string

URLKey gets url from request to use it as cache key admins will have different keys in order to prevent leak of admin-only data to regular users

func URLKeyWithUser

func URLKeyWithUser(r *http.Request) string

URLKeyWithUser gets url from request to use it as cache key and attaching user ID admins will have different keys in order to prevent leak of admin-only data to regular users

Types

type KeyStore

type KeyStore interface {
	Key() (key string, err error)
}

KeyStore defines sub-interface for consumers needed just a key

type LoadingCache added in v1.5.0

type LoadingCache interface {
	Get(key lcw.Key, fn func() ([]byte, error)) (data []byte, err error) // load from cache if found or put to cache and return
	Flush(req lcw.FlusherRequest)                                        // evict matched records
}

LoadingCache defines interface for caching

type Migrator

type Migrator struct {
	Cache             LoadingCache
	NativeImporter    migrator.Importer
	DisqusImporter    migrator.Importer
	WordPressImporter migrator.Importer
	NativeExporter    migrator.Exporter
	URLMapperMaker    migrator.MapperMaker
	KeyStore          KeyStore
	// contains filtered or unexported fields
}

Migrator rest with import and export controllers

type Rest

type Rest struct {
	Version string

	DataService      *service.DataStore
	Authenticator    *auth.Service
	Cache            LoadingCache
	ImageProxy       *proxy.Image
	CommentFormatter *store.CommentFormatter
	Migrator         *Migrator
	NotifyService    *notify.Service
	ImageService     *image.Service
	Streamer         *Streamer

	AnonVote        bool
	WebRoot         string
	RemarkURL       string
	AdminEmail      string
	ReadOnlyAge     int
	SharedSecret    string
	ScoreThresholds struct {
		Low      int
		Critical int
	}
	UpdateLimiter      float64
	EmailNotifications bool
	EmojiEnabled       bool
	SimpleView         bool

	SSLConfig SSLConfig
	// 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

type SSLConfig

type SSLConfig struct {
	SSLMode      sslMode
	Cert         string
	Key          string
	Port         int
	ACMELocation string
	ACMEEmail    string
}

SSLConfig holds all ssl params for rest server

type Streamer added in v1.4.0

type Streamer struct {
	TimeOut   time.Duration
	Refresh   time.Duration
	MaxActive int32
	// contains filtered or unexported fields
}

Streamer creates endless stream of \n separated json records send to remote client

func (*Streamer) Activate added in v1.4.0

func (s *Streamer) Activate(ctx context.Context, eventFn func() steamEventFn, w io.Writer) error

Activate starts blocking function streaming update created by eventFn to ResponseWriter canceled on context or inactivity timeout note: eventFn is a closure needed to allow state management inside eventFn

Jump to

Keyboard shortcuts

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