mandible: github.com/Imgur/mandible/server Index | Files

package server

import "github.com/Imgur/mandible/server"

Index

Package Files

authenticator.go server.go stats.go

Variables

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.")
)

type AuthenticatedUser Uses

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

type Authenticator Uses

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

type DatadogStats Uses

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

func NewDatadogStats Uses

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

func (*DatadogStats) Error Uses

func (d *DatadogStats) Error(code int)

func (*DatadogStats) LogStartup Uses

func (d *DatadogStats) LogStartup()

func (*DatadogStats) Request Uses

func (d *DatadogStats) Request(url string)

func (*DatadogStats) ResponseTime Uses

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

func (*DatadogStats) Thumbnail Uses

func (d *DatadogStats) Thumbnail(name string)

func (*DatadogStats) Upload Uses

func (d *DatadogStats) Upload(source string)

type DiscardStats Uses

type DiscardStats struct{}

func (*DiscardStats) Error Uses

func (d *DiscardStats) Error(code int)

func (*DiscardStats) LogStartup Uses

func (d *DiscardStats) LogStartup()

func (*DiscardStats) Request Uses

func (d *DiscardStats) Request(url string)

func (*DiscardStats) ResponseTime Uses

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

func (*DiscardStats) Thumbnail Uses

func (d *DiscardStats) Thumbnail(name string)

func (*DiscardStats) Upload Uses

func (d *DiscardStats) Upload(source string)

type HMACAuthenticator Uses

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

func NewHMACAuthenticatorSHA256 Uses

func NewHMACAuthenticatorSHA256(key []byte) *HMACAuthenticator

func (*HMACAuthenticator) GetUser Uses

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

func (*HMACAuthenticator) SetTime Uses

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

type ImageResponse Uses

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 Uses

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

type PassthroughAuthenticator Uses

type PassthroughAuthenticator struct{}

func (*PassthroughAuthenticator) GetUser Uses

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

type RuntimeStats Uses

type RuntimeStats interface {
    LogStartup()

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

type Server Uses

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

func NewAuthenticatedServer Uses

func NewAuthenticatedServer(c *config.Configuration, strategy imageprocessor.ImageProcessorStrategy, auth Authenticator, stats RuntimeStats) *Server

func NewServer Uses

func NewServer(c *config.Configuration, strategy imageprocessor.ImageProcessorStrategy, stats RuntimeStats) *Server

func (*Server) Configure Uses

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

type ServerResponse Uses

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 Uses

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

type UserError Uses

type UserError struct {
    UserFacingMessage error
    LogMessage        error
}

Package server imports 22 packages (graph) and is imported by 3 packages. Updated 2016-07-16. Refresh now. Tools for package owners.