Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultWrapper(orig func(http.ResponseWriter, *http.Request) int) func(http.ResponseWriter, *http.Request)
- func LogInit(traceHandle io.Writer, infoHandle io.Writer, warningHandle io.Writer, ...)
- func ParseURL(url string) []string
- func ReplaceBoolWithEnv(spot *bool, key string) (err error)
- func ReplaceIntWithEnv(spot *int, key string) (err error)
- func ReplaceStringWithEnv(spot *string, key string) (err error)
- func RespondExpectationFailed(respWriter http.ResponseWriter, req *http.Request) int
- func RespondInternalServerError(respWriter http.ResponseWriter, req *http.Request) int
- func RespondLengthRequired(respWriter http.ResponseWriter, req *http.Request) int
- func RespondMethodNotAllowed(respWriter http.ResponseWriter, req *http.Request) int
- func RespondNotAcceptable(respWriter http.ResponseWriter, req *http.Request) int
- func RespondNotFound(respWriter http.ResponseWriter, req *http.Request) int
- func RespondOK(respWriter http.ResponseWriter, req *http.Request) int
- func RespondOKWithBody(body []byte, respWriter http.ResponseWriter, req *http.Request) int
- func RespondOKWithReader(r io.Reader, respWriter http.ResponseWriter, req *http.Request) int
- func RespondTemporaryRedirect(respWriter http.ResponseWriter, req *http.Request, url string) int
- func RespondUnauthorized(respWriter http.ResponseWriter, req *http.Request) int
- func RespondWithBody(body []byte, code int, respWriter http.ResponseWriter, req *http.Request) int
- func RespondWithReader(r io.Reader, code int, respWriter http.ResponseWriter, req *http.Request) int
- type FmkSession
- func (sess *FmkSession) Del(key string) error
- func (sess *FmkSession) Get(key string) string
- func (sess *FmkSession) GetCookie() *http.Cookie
- func (sess *FmkSession) GetLastUpdate() time.Time
- func (sess *FmkSession) SessionID() string
- func (sess *FmkSession) Set(key, value string) error
- func (sess *FmkSession) Update()
- type FmkSessionManager
- func (sm *FmkSessionManager) GC()
- func (sm *FmkSessionManager) GetSession(writer http.ResponseWriter, req *http.Request) (Session, error)
- func (sm *FmkSessionManager) SetGCRate(gcRate time.Duration)
- func (sm *FmkSessionManager) SetSessionDomain(domainName string)
- func (sm *FmkSessionManager) SetSessionKey(sessionKey []byte)
- func (sm *FmkSessionManager) SetSessionMaxLife(ml time.Duration)
- func (sm *FmkSessionManager) SetSessionName(sessionName string)
- func (sm *FmkSessionManager) SetSessionPath(path string)
- func (sm *FmkSessionManager) Sign(base string) string
- func (sm *FmkSessionManager) Validate(sid string) error
- type FmkWebServer
- func (ws *FmkWebServer) FixTimeouts()
- func (ws *FmkWebServer) HandleFunc(path string, handleFunc func(http.ResponseWriter, *http.Request) int)
- func (ws *FmkWebServer) Listen(address string, port int) error
- func (ws *FmkWebServer) ServeStatic(staticDir, pathRoot string)
- func (ws *FmkWebServer) SetDefaultWrapper(wf WrapperFunc)
- func (ws *FmkWebServer) SetTLSConf(conf *tls.Config)
- func (ws *FmkWebServer) SetTLSServing(certPath, keyPath string)
- type Logger
- type Session
- type SessionManager
- type WebServer
- type WrapperFunc
Constants ¶
View Source
const ( SIDBaseLen int = 32 CipherKeyLength int = 32 )
View Source
const (
FRONT_SLASH = 47 // literally ascii/utf8 for '/'
)
Variables ¶
View Source
var ( DEFAULT_READ_TIMEOUT = time.Duration(5) * time.Second DEFAULT_WRITE_TIMEOUT = time.Duration(30) * time.Second DEFAULT_IDLE_TIMEOUT = time.Duration(240) * time.Second )
View Source
var ( ALPHA []byte = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") DefaultSessionName string = "FMKSession" DefaultSessionKey []byte = []byte("PleaseChangeMe;MoreRandom=Better") SIDInUse error = errors.New("SID In Use") SIDMissing error = errors.New("SID Missing") SIDBaseString string = "Kitty" BadSID error = errors.New("Invalid SID") LenMismatch error = errors.New("Mismatched Length") KeyTooShort error = errors.New("KeyTooShort") SessionKeyUnset error = errors.New("Session Key Unset") )
View Source
var (
CipherTextTooShort error = errors.New("FMK: Ciphertext too short")
)
View Source
var (
DEFAULT_COPY_BUFFER_SIZE = 4096
)
View Source
var DefaultMessages = map[int][]byte{ http.StatusOK: []byte("OK\n"), http.StatusNotFound: []byte("Not Found\n"), http.StatusUnauthorized: []byte("Unauthorized\n"), http.StatusNotAcceptable: []byte("Not Acceptable\n"), http.StatusLengthRequired: []byte("Length Required\n"), http.StatusMethodNotAllowed: []byte("Method Not Allowed\n"), http.StatusInternalServerError: []byte("Internal Server Error\n"), http.StatusExpectationFailed: []byte("Expectation Failed\n"), }
Functions ¶
func DefaultWrapper ¶
func DefaultWrapper(orig func(http.ResponseWriter, *http.Request) int) func(http.ResponseWriter, *http.Request)
func ReplaceBoolWithEnv ¶
func ReplaceIntWithEnv ¶
func ReplaceStringWithEnv ¶
func RespondExpectationFailed ¶
func RespondExpectationFailed(respWriter http.ResponseWriter, req *http.Request) int
func RespondInternalServerError ¶
func RespondInternalServerError(respWriter http.ResponseWriter, req *http.Request) int
func RespondLengthRequired ¶
func RespondLengthRequired(respWriter http.ResponseWriter, req *http.Request) int
func RespondMethodNotAllowed ¶
func RespondMethodNotAllowed(respWriter http.ResponseWriter, req *http.Request) int
func RespondNotAcceptable ¶
func RespondNotAcceptable(respWriter http.ResponseWriter, req *http.Request) int
func RespondNotFound ¶
func RespondNotFound(respWriter http.ResponseWriter, req *http.Request) int
func RespondOKWithBody ¶
func RespondOKWithReader ¶
func RespondUnauthorized ¶
func RespondUnauthorized(respWriter http.ResponseWriter, req *http.Request) int
func RespondWithBody ¶
func RespondWithReader ¶
Types ¶
type FmkSession ¶
type FmkSession struct { Book map[string]string SID string DomainName string Path string SessionName string LastUpdate time.Time }
func (*FmkSession) Del ¶
func (sess *FmkSession) Del(key string) error
func (*FmkSession) Get ¶
func (sess *FmkSession) Get(key string) string
func (*FmkSession) GetCookie ¶
func (sess *FmkSession) GetCookie() *http.Cookie
func (*FmkSession) GetLastUpdate ¶
func (sess *FmkSession) GetLastUpdate() time.Time
func (*FmkSession) SessionID ¶
func (sess *FmkSession) SessionID() string
func (*FmkSession) Set ¶
func (sess *FmkSession) Set(key, value string) error
func (*FmkSession) Update ¶
func (sess *FmkSession) Update()
type FmkSessionManager ¶
type FmkSessionManager struct { SessionName string SessionKey []byte DomainName string Path string Lock sync.Mutex SessionMaxLife time.Duration GCRate time.Duration Book map[string]Session }
func NewSessionManager ¶
func NewSessionManager(sessionName string, sml, gcrate time.Duration) *FmkSessionManager
func (*FmkSessionManager) GC ¶
func (sm *FmkSessionManager) GC()
func (*FmkSessionManager) GetSession ¶
func (sm *FmkSessionManager) GetSession(writer http.ResponseWriter, req *http.Request) (Session, error)
func (*FmkSessionManager) SetGCRate ¶
func (sm *FmkSessionManager) SetGCRate(gcRate time.Duration)
func (*FmkSessionManager) SetSessionDomain ¶
func (sm *FmkSessionManager) SetSessionDomain(domainName string)
func (*FmkSessionManager) SetSessionKey ¶
func (sm *FmkSessionManager) SetSessionKey(sessionKey []byte)
func (*FmkSessionManager) SetSessionMaxLife ¶
func (sm *FmkSessionManager) SetSessionMaxLife(ml time.Duration)
func (*FmkSessionManager) SetSessionName ¶
func (sm *FmkSessionManager) SetSessionName(sessionName string)
func (*FmkSessionManager) SetSessionPath ¶
func (sm *FmkSessionManager) SetSessionPath(path string)
func (*FmkSessionManager) Sign ¶
func (sm *FmkSessionManager) Sign(base string) string
func (*FmkSessionManager) Validate ¶
func (sm *FmkSessionManager) Validate(sid string) error
type FmkWebServer ¶
type FmkWebServer struct { ReadTimeout *time.Duration WriteTimeout *time.Duration IdleTimeout *time.Duration // contains filtered or unexported fields }
var Server FmkWebServer
func (*FmkWebServer) FixTimeouts ¶
func (ws *FmkWebServer) FixTimeouts()
func (*FmkWebServer) HandleFunc ¶
func (ws *FmkWebServer) HandleFunc(path string, handleFunc func(http.ResponseWriter, *http.Request) int)
func (*FmkWebServer) ServeStatic ¶
func (ws *FmkWebServer) ServeStatic(staticDir, pathRoot string)
func (*FmkWebServer) SetDefaultWrapper ¶
func (ws *FmkWebServer) SetDefaultWrapper(wf WrapperFunc)
func (*FmkWebServer) SetTLSConf ¶
func (ws *FmkWebServer) SetTLSConf(conf *tls.Config)
func (*FmkWebServer) SetTLSServing ¶
func (ws *FmkWebServer) SetTLSServing(certPath, keyPath string)
type Session ¶
type Session interface { Set(key, value string) error Get(key string) string Del(key string) error SessionID() string GetLastUpdate() time.Time Update() GetCookie() *http.Cookie }
func NewSession ¶
type SessionManager ¶
type SessionManager interface { GetSession(respWriter http.ResponseWriter, req *http.Request) (Session, error) SetSessionKey(sessionKey []byte) SetSessionName(sessionName string) SetSessionDomain(domainName string) SetSessionPath(pathName string) SetGCRate(gcRate time.Duration) SetSessionMaxLife(ml time.Duration) // contains filtered or unexported methods }
var Sessions SessionManager
type WebServer ¶
type WebServer interface { HandleFunc(path string, handleFunc func(http.ResponseWriter, *http.Request)) Listen(address string, port int) error ServeStatic(staticDir, pathRoot string) SetReadTimeout(timeout *time.Duration) SetWriteTimeout(timeout *time.Duration) SetIdleTimeout(timeout *time.Duration) SetTLSConf(conf *tls.Config) SetTLSServing(certFile, keyFile string) SetDefaultWrapper(WrapperFunc) }
type WrapperFunc ¶
type WrapperFunc func(func(http.ResponseWriter, *http.Request) int) func(http.ResponseWriter, *http.Request)
Click to show internal directories.
Click to hide internal directories.