Documentation ¶
Index ¶
- Constants
- func DecodeJsonPayload(r *http.Request, v interface{}) error
- func GetApi(config *Config) *martini.ClassicMartini
- func NewSessionHistoryHandler(size int, name string) martini.Handler
- func RandomColor() [3]byte
- func Solid16x16gifDatauri(color [3]byte) string
- type BaseStorage
- type Bin
- type BinRecord
- type Config
- type ErrorMsg
- type History
- type MemoryStorage
- func (storage *MemoryStorage) CreateBin(bin *Bin) error
- func (storage *MemoryStorage) CreateRequest(bin *Bin, req *Request) error
- func (storage *MemoryStorage) LookupBin(name string) (*Bin, error)
- func (storage *MemoryStorage) LookupBins(names []string) ([]*Bin, error)
- func (storage *MemoryStorage) LookupRequest(binName, id string) (*Request, error)
- func (storage *MemoryStorage) LookupRequests(binName string, from int, to int) ([]*Request, error)
- func (storage *MemoryStorage) StartCleaning(timeout int)
- func (storage *MemoryStorage) StopCleaning()
- func (storage *MemoryStorage) UpdateBin(_ *Bin) error
- type RandomString
- type RedisConfig
- type RedisStorage
- func (storage *RedisStorage) CreateBin(bin *Bin) error
- func (storage *RedisStorage) CreateRequest(bin *Bin, req *Request) (err error)
- func (storage *RedisStorage) Dump(v interface{}) (data []byte, err error)
- func (storage *RedisStorage) Load(data []byte, v interface{}) error
- func (storage *RedisStorage) LookupBin(name string) (bin *Bin, err error)
- func (storage *RedisStorage) LookupBins(names []string) ([]*Bin, error)
- func (storage *RedisStorage) LookupRequest(binName string, id string) (req *Request, err error)
- func (storage *RedisStorage) LookupRequests(binName string, from int, to int) ([]*Request, error)
- func (storage *RedisStorage) StartCleaning(timeout int)
- func (storage *RedisStorage) StopCleaning()
- func (storage *RedisStorage) UpdateBin(bin *Bin) (err error)
- type Request
- type SessionHistory
- type Storage
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 GetApi ¶
func GetApi(config *Config) *martini.ClassicMartini
func RandomColor ¶
func RandomColor() [3]byte
func Solid16x16gifDatauri ¶
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 (*Bin) SetPrivate ¶
func (bin *Bin) SetPrivate()
type BinRecord ¶
type BinRecord struct {
// contains filtered or unexported fields
}
func (*BinRecord) ShrinkRequests ¶
type Config ¶
type Config struct { SessionSecret string Storage string RedisConfig }
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 (*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 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 (*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"` }
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 }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.