server

package
v0.0.0-...-fedf337 Latest Latest
Warning

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

Go to latest
Published: May 31, 2017 License: MIT Imports: 22 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoAuthentication = errors.New("No authentication scheme was configured.")
	ErrEmptyAuth        = errors.New("Empty or missing authentication header.")
	ErrNoGrantTime      = errors.New("No grant time specified in the authentication grant.")
	ErrExpiredGrant     = errors.New("The authentication grant has expired.")
	ErrMACMismatch      = errors.New("The provided message authentication code is invalid for the given message.")
)

Functions

This section is empty.

Types

type AuthenticatedUser

type AuthenticatedUser struct {
	UserID               string    `json:"user_id"`
	GrantTime            time.Time `json:"grant_time"`
	GrantDurationSeconds int64     `json:"grant_duration_sec"`
}

type Authenticator

type Authenticator interface {
	GetUser(*http.Request) (*AuthenticatedUser, error)
}

type DatadogStats

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

func NewDatadogStats

func NewDatadogStats(datadogHost string) (*DatadogStats, error)

func (*DatadogStats) Error

func (d *DatadogStats) Error(code int)

func (*DatadogStats) LogStartup

func (d *DatadogStats) LogStartup()

func (*DatadogStats) Request

func (d *DatadogStats) Request(url string)

func (*DatadogStats) ResponseTime

func (d *DatadogStats) ResponseTime(elapsed time.Duration, url string)

func (*DatadogStats) Thumbnail

func (d *DatadogStats) Thumbnail(name string)

func (*DatadogStats) Upload

func (d *DatadogStats) Upload(source string)

type DiscardStats

type DiscardStats struct{}

func (*DiscardStats) Error

func (d *DiscardStats) Error(code int)

func (*DiscardStats) LogStartup

func (d *DiscardStats) LogStartup()

func (*DiscardStats) Request

func (d *DiscardStats) Request(url string)

func (*DiscardStats) ResponseTime

func (d *DiscardStats) ResponseTime(elapsed time.Duration, url string)

func (*DiscardStats) Thumbnail

func (d *DiscardStats) Thumbnail(name string)

func (*DiscardStats) Upload

func (d *DiscardStats) Upload(source string)

type HMACAuthenticator

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

func NewHMACAuthenticatorSHA256

func NewHMACAuthenticatorSHA256(key []byte) *HMACAuthenticator

func (*HMACAuthenticator) GetUser

func (auth *HMACAuthenticator) GetUser(req *http.Request) (*AuthenticatedUser, error)

func (*HMACAuthenticator) SetTime

func (auth *HMACAuthenticator) SetTime(t time.Time)

type ImageResponse

type ImageResponse struct {
	Link    string                 `json:"link"`
	Mime    string                 `json:"mime"`
	Name    string                 `json:"name"`
	Hash    string                 `json:"hash"`
	Size    int64                  `json:"size"`
	Width   int                    `json:"width"`
	Height  int                    `json:"height"`
	OCRText string                 `json:"ocrtext"`
	Thumbs  map[string]interface{} `json:"thumbs"`
	UserID  string                 `json:"user_id"`
}

type OcrResponse

type OcrResponse struct {
	Hash    string `json:"hash"`
	OCRText string `json:"ocrtext"`
}

type PassthroughAuthenticator

type PassthroughAuthenticator struct{}

func (*PassthroughAuthenticator) GetUser

type RuntimeStats

type RuntimeStats interface {
	LogStartup()

	Request(url string)
	ResponseTime(elapsed time.Duration, url string)
	Thumbnail(name string)
	Upload(source string)
	Error(code int)
}

type Server

type Server struct {
	Config     *config.Configuration
	HTTPClient *http.Client
	ImageStore imagestore.ImageStore
	// contains filtered or unexported fields
}

func (*Server) Configure

func (s *Server) Configure(muxer *http.ServeMux)

type ServerResponse

type ServerResponse struct {
	Error   string      `json:"error,omitempty"`
	Data    interface{} `json:"data,omitempty"`
	Status  int         `json:"status"`
	Success *bool       `json:"success"` // the empty value is the nil pointer, because this is a computed property
}

func (*ServerResponse) Write

func (resp *ServerResponse) Write(w http.ResponseWriter, s RuntimeStats)

type UserError

type UserError struct {
	UserFacingMessage error
	LogMessage        error
}

Jump to

Keyboard shortcuts

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