skimmer

package
v0.0.0-...-02a6525 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2014 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	REQUEST_BODY_SIZE = 1024 * 30
	MAX_REQUEST_COUNT = 20
	BIN_LIFETIME      = 60 * 60 * 24 * 2
)
View Source
const (
	KEY_SEPARATOR    = "|"
	BIN_KEY          = "bins"
	REQUESTS_KEY     = "rq"
	REQUEST_HASH_KEY = "rhsh"
	CLEANING_SET     = "cln"
	CLEANING_FACTOR  = 3
)

Variables

This section is empty.

Functions

func DecodeJsonPayload

func DecodeJsonPayload(r *http.Request, v interface{}) error

func GetApi

func GetApi(config *Config) *martini.ClassicMartini

func NewSessionHistoryHandler

func NewSessionHistoryHandler(size int, name string) martini.Handler

func RandomColor

func RandomColor() [3]byte

func Solid16x16gifDatauri

func Solid16x16gifDatauri(color [3]byte) string

Types

type BaseStorage

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

type Bin

type Bin struct {
	Name         string  `json:"name"`
	Created      int64   `json:"created"`
	Updated      int64   `json:"updated"`
	RequestCount int     `json:"requestCount"`
	Color        [3]byte `json:"color"`
	Favicon      string  `json:"favicon"`
	Private      bool    `json:"private"`
	SecretKey    string  `json:"-"`
}

func NewBin

func NewBin() *Bin

func (*Bin) SetPrivate

func (bin *Bin) SetPrivate()

type BinRecord

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

func (*BinRecord) ShrinkRequests

func (binRecord *BinRecord) ShrinkRequests(size int)

type Config

type Config struct {
	SessionSecret string
	Storage       string
	RedisConfig
}

type ErrorMsg

type ErrorMsg struct {
	Error string `json:"error"`
}

type History

type History interface {
	All() []string
	Add(string)
}

type MemoryStorage

type MemoryStorage struct {
	BaseStorage
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMemoryStorage

func NewMemoryStorage(maxRequests int, binLifetime int64) *MemoryStorage

func (*MemoryStorage) CreateBin

func (storage *MemoryStorage) CreateBin(bin *Bin) error

func (*MemoryStorage) CreateRequest

func (storage *MemoryStorage) CreateRequest(bin *Bin, req *Request) error

func (*MemoryStorage) LookupBin

func (storage *MemoryStorage) LookupBin(name string) (*Bin, error)

func (*MemoryStorage) LookupBins

func (storage *MemoryStorage) LookupBins(names []string) ([]*Bin, error)

func (*MemoryStorage) LookupRequest

func (storage *MemoryStorage) LookupRequest(binName, id string) (*Request, error)

func (*MemoryStorage) LookupRequests

func (storage *MemoryStorage) LookupRequests(binName string, from int, to int) ([]*Request, error)

func (*MemoryStorage) StartCleaning

func (storage *MemoryStorage) StartCleaning(timeout int)

func (*MemoryStorage) StopCleaning

func (storage *MemoryStorage) StopCleaning()

func (*MemoryStorage) UpdateBin

func (storage *MemoryStorage) UpdateBin(_ *Bin) error

type RandomString

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

func NewRandomString

func NewRandomString(pool string) *RandomString

func (*RandomString) Generate

func (rs *RandomString) Generate(length int) (r string)

type RedisConfig

type RedisConfig struct {
	RedisAddr     string
	RedisPassword string
	RedisPrefix   string
}

type RedisStorage

type RedisStorage struct {
	BaseStorage
	// contains filtered or unexported fields
}

func NewRedisStorage

func NewRedisStorage(server, password, prefix string, maxRequests int, binLifetime int64) *RedisStorage

func (*RedisStorage) CreateBin

func (storage *RedisStorage) CreateBin(bin *Bin) error

func (*RedisStorage) CreateRequest

func (storage *RedisStorage) CreateRequest(bin *Bin, req *Request) (err error)

func (*RedisStorage) Dump

func (storage *RedisStorage) Dump(v interface{}) (data []byte, err error)

func (*RedisStorage) Load

func (storage *RedisStorage) Load(data []byte, v interface{}) error

func (*RedisStorage) LookupBin

func (storage *RedisStorage) LookupBin(name string) (bin *Bin, err error)

func (*RedisStorage) LookupBins

func (storage *RedisStorage) LookupBins(names []string) ([]*Bin, error)

func (*RedisStorage) LookupRequest

func (storage *RedisStorage) LookupRequest(binName string, id string) (req *Request, err error)

func (*RedisStorage) LookupRequests

func (storage *RedisStorage) LookupRequests(binName string, from int, to int) ([]*Request, error)

func (*RedisStorage) StartCleaning

func (storage *RedisStorage) StartCleaning(timeout int)

func (*RedisStorage) StopCleaning

func (storage *RedisStorage) StopCleaning()

func (*RedisStorage) UpdateBin

func (storage *RedisStorage) UpdateBin(bin *Bin) (err error)

type Request

type Request struct {
	Id      string `json:"id"`
	Created int64  `json:"created"`

	Method        string              `json:"method"` // GET, POST, PUT, etc.
	Proto         string              `json:"proto"`  // "HTTP/1.0"
	Header        http.Header         `json:"header"`
	ContentLength int64               `json:"contentLength"`
	RemoteAddr    string              `json:"remoteAddr"`
	Host          string              `json:"host"`
	RequestURI    string              `json:"requestURI"`
	Body          string              `json:"body"`
	FormValue     map[string][]string `json:"formValue"`
	FormFile      []string            `json:"formFile"`
}

func NewRequest

func NewRequest(httpRequest *http.Request, maxBodySize int) *Request

type SessionHistory

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

func (*SessionHistory) Add

func (history *SessionHistory) Add(name string)

func (*SessionHistory) All

func (history *SessionHistory) All() []string

type Storage

type Storage interface {
	LookupBin(name string) (*Bin, error)                             // get one bin element by name
	LookupBins(names []string) ([]*Bin, error)                       // get slice of bin elements
	LookupRequest(binName, id string) (*Request, error)              // get request from bin by id
	LookupRequests(binName string, from, to int) ([]*Request, error) // get slice of requests from bin by position
	CreateBin(bin *Bin) error                                        // create bin in memory storage
	UpdateBin(bin *Bin) error                                        // save
	CreateRequest(bin *Bin, req *Request) error
}

Jump to

Keyboard shortcuts

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