Documentation
¶
Index ¶
- func CreateEncryptedCookie(w http.ResponseWriter, secureCookie securecookie.SecureCookie, name string, ...) (*http.Cookie, error)
- func CreateEncryptedCookieWithDefaults(w http.ResponseWriter, secureCookie securecookie.SecureCookie, name string, ...) (*http.Cookie, error)
- func GetEnv(key, defaultValue string) string
- func ReadEncryptedCookie(r *http.Request, secureCookie securecookie.SecureCookie, name string) (map[string]string, error)
- type Context
- func (c *Context) Data(code int, data []byte)
- func (c *Context) Decrypt(encrypted string, passphrase string) ([]byte, error)
- func (c *Context) DeleteCookie(name string)
- func (c *Context) Encrypt(data []byte, passphrase string) (string, error)
- func (c *Context) GetCookie(name string) (*http.Cookie, error)
- func (c *Context) GetDB() *database.DB
- func (c *Context) GetSession(name string) sessions.Store
- func (c *Context) HTML(code int, htmlContent string)
- func (c *Context) HashByte(value []byte) [32]byte
- func (c *Context) HashString(value string) [32]byte
- func (c *Context) HashStringToString(value string) string
- func (c *Context) Image(code int, contentType string, imageData []byte)
- func (c *Context) JSON(code int, i interface{})
- func (c *Context) Log() *log.Logger
- func (c *Context) Parms() map[string]string
- func (c *Context) PgxExec(ctx context.Context, query string, args ...interface{}) (pgconn.CommandTag, error)
- func (c *Context) PgxExecNoResult(ctx context.Context, query string, args ...interface{}) error
- func (c *Context) PgxQuery(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
- func (c *Context) PgxQueryRow(ctx context.Context, query string, args ...interface{}) pgx.Row
- func (c *Context) ProxyMedia(mediaURL string)
- func (c *Context) Redirect(code int, url string)
- func (c *Context) SetCookie(cookie *http.Cookie)
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) SetSession(s *Session)
- func (c *Context) SqlExec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (c *Context) SqlExecNoResult(ctx context.Context, query string, args ...interface{}) error
- func (c *Context) SqlQuery(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (c *Context) SqlQueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (c *Context) Status(code int)
- func (c *Context) String(code int, i interface{})
- func (c *Context) XML(code int, i interface{})
- type HandlerFunc
- type MiddlewareFunc
- type Session
- func (w *Session) Cookie(name string) *securecookie.SecureCookie
- func (w *Session) Cookies() map[string]*securecookie.SecureCookie
- func (w *Session) CreateDefaultEncryptedCookie(wr http.ResponseWriter, cookieName string, value map[string]interface{}, ...) (*http.Cookie, error)
- func (w *Session) CreateDefaultEncryptedCookieWithDefaults(wr http.ResponseWriter, cookieName string, value map[string]interface{}) (*http.Cookie, error)
- func (w *Session) CreateEncryptedCookie(wr http.ResponseWriter, name string, cookieName string, ...) (*http.Cookie, error)
- func (w *Session) CreateEncryptedCookieWithDefaults(wr http.ResponseWriter, name string, cookieName string, ...) (*http.Cookie, error)
- func (w *Session) DefaultCookie() *securecookie.SecureCookie
- func (w *Session) DefaultSession() sessions.Store
- func (w *Session) DeleteCookie(name string)
- func (w *Session) DeleteStore(name string)
- func (w *Session) ReadDefaultEncryptedCookie(r *http.Request, name string, cookieName string) (map[string]string, error)
- func (w *Session) ReadEncryptedCookie(r *http.Request, name string, cookieName string) (map[string]string, error)
- func (w *Session) SetCookie(name string, s *securecookie.SecureCookie)
- func (w *Session) SetDefaultCookie(s *securecookie.SecureCookie)
- func (w *Session) SetDefaultCookieName(name string)
- func (w *Session) SetDefaultStore(s sessions.Store)
- func (w *Session) SetDefaultStoreName(name string)
- func (w *Session) SetStore(name string, s sessions.Store)
- func (w *Session) Store(name string) sessions.Store
- func (w *Session) Stores() map[string]sessions.Store
- type Way
- func (w *Way) Close() error
- func (w *Way) DELETE(path string, handler HandlerFunc)
- func (w *Way) Db() *database.DB
- func (w *Way) GET(path string, handler HandlerFunc)
- func (w *Way) HEAD(path string, handler HandlerFunc)
- func (w *Way) HandleFunc(path string, handler HandlerFunc)
- func (w *Way) InitDBFromConfig() error
- func (w *Way) Log() *log.Logger
- func (w *Way) OPTIONS(path string, handler HandlerFunc)
- func (w *Way) PATCH(path string, handler HandlerFunc)
- func (w *Way) POST(path string, handler HandlerFunc)
- func (w *Way) PUT(path string, handler HandlerFunc)
- func (w *Way) SetDB(db *database.DB)
- func (w *Way) SetDBConnection(db interface{}, driver string)
- func (w *Way) SetListener(listener net.Listener)
- func (w *Way) SetLogger(logger *log.Logger)
- func (w *Way) SetRouter(router *mux.Router)
- func (w *Way) SetServer(server *http.Server)
- func (w *Way) SetSession(s *Session)
- func (w *Way) Shutdown(ctx context.Context) error
- func (w *Way) Start(address string) error
- func (w *Way) Use(middleware ...MiddlewareFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateEncryptedCookie ¶ added in v0.3.1
func CreateEncryptedCookie( w http.ResponseWriter, secureCookie securecookie.SecureCookie, name string, value map[string]interface{}, path string, maxAge int, httpOnly bool, secure bool) (*http.Cookie, error)
func CreateEncryptedCookieWithDefaults ¶ added in v0.3.1
func CreateEncryptedCookieWithDefaults( w http.ResponseWriter, secureCookie securecookie.SecureCookie, name string, value map[string]interface{}) (*http.Cookie, error)
func GetEnv ¶ added in v0.3.1
GetEnv retrieves the environment variable value or a default value if not set
func ReadEncryptedCookie ¶ added in v0.3.1
func ReadEncryptedCookie(r *http.Request, secureCookie securecookie.SecureCookie, name string) (map[string]string, error)
Types ¶
type Context ¶
type Context struct {
Response http.ResponseWriter
Request *http.Request
Session *Session
Logger *log.Logger
// contains filtered or unexported fields
}
Response is the standard go HTTP response writer. Request is the standard go HTTP request. db is the way database connection. Session is the way session.
func NewContext ¶
func (*Context) DeleteCookie ¶ added in v0.2.4
func (*Context) GetSession ¶ added in v0.2.4
func (*Context) HashString ¶ added in v0.2.4
func (*Context) HashStringToString ¶ added in v0.2.6
func (*Context) PgxExecNoResult ¶ added in v0.2.0
func (*Context) PgxQueryRow ¶ added in v0.2.0
func (*Context) ProxyMedia ¶ added in v0.2.0
func (*Context) SetSession ¶ added in v0.2.4
func (*Context) SqlExecNoResult ¶ added in v0.1.0
func (*Context) SqlQueryRow ¶ added in v0.1.0
type HandlerFunc ¶
type HandlerFunc func(*Context)
HandlerFunc is a function type that represents a handler for a request. It takes a *Context parameter, which provides information about the request and allows the handler to generate a response.
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc represents a function that takes a HandlerFunc and returns a modified HandlerFunc.
type Session ¶ added in v0.3.1
type Session struct {
// contains filtered or unexported fields
}
defaultStore is the name of the default session store. defaultCookie is the name of the default session cookie. stores is a map of session stores. cookies is a map of secure cookies.
func NewSession ¶ added in v0.3.1
func NewSession() *Session
func (*Session) Cookie ¶ added in v0.3.1
func (w *Session) Cookie(name string) *securecookie.SecureCookie
func (*Session) Cookies ¶ added in v0.3.1
func (w *Session) Cookies() map[string]*securecookie.SecureCookie
func (*Session) CreateDefaultEncryptedCookie ¶ added in v0.3.1
func (*Session) CreateDefaultEncryptedCookieWithDefaults ¶ added in v0.3.1
func (*Session) CreateEncryptedCookie ¶ added in v0.3.1
func (*Session) CreateEncryptedCookieWithDefaults ¶ added in v0.3.1
func (*Session) DefaultCookie ¶ added in v0.3.1
func (w *Session) DefaultCookie() *securecookie.SecureCookie
func (*Session) DefaultSession ¶ added in v0.3.1
func (*Session) DeleteCookie ¶ added in v0.3.1
func (*Session) DeleteStore ¶ added in v0.3.1
func (*Session) ReadDefaultEncryptedCookie ¶ added in v0.3.1
func (*Session) ReadEncryptedCookie ¶ added in v0.3.1
func (*Session) SetCookie ¶ added in v0.3.1
func (w *Session) SetCookie(name string, s *securecookie.SecureCookie)
func (*Session) SetDefaultCookie ¶ added in v0.3.1
func (w *Session) SetDefaultCookie(s *securecookie.SecureCookie)
func (*Session) SetDefaultCookieName ¶ added in v0.3.1
func (*Session) SetDefaultStore ¶ added in v0.3.1
func (*Session) SetDefaultStoreName ¶ added in v0.3.1
type Way ¶
type Way struct {
// Server is the HTTP server.
Server *http.Server
// Listener is the network listener.
Listener net.Listener
// Logger is the logger.
Logger *log.Logger
// contains filtered or unexported fields
}
func New ¶
func New() *Way
New creates a new instance of Way. It initializes the sessions and sets session defaults if necessary. It returns a pointer to the newly created Way instance.
func (*Way) DELETE ¶
func (w *Way) DELETE(path string, handler HandlerFunc)
func (*Way) HEAD ¶
func (w *Way) HEAD(path string, handler HandlerFunc)
func (*Way) HandleFunc ¶
func (w *Way) HandleFunc(path string, handler HandlerFunc)
HandleFunc registers a new route with a matcher for the URL path.
func (*Way) InitDBFromConfig ¶ added in v0.3.1
InitDBFromConfig initializes the database connection from environment variables.
func (*Way) OPTIONS ¶
func (w *Way) OPTIONS(path string, handler HandlerFunc)
func (*Way) PATCH ¶
func (w *Way) PATCH(path string, handler HandlerFunc)
func (*Way) POST ¶
func (w *Way) POST(path string, handler HandlerFunc)
func (*Way) PUT ¶
func (w *Way) PUT(path string, handler HandlerFunc)
func (*Way) SetDB ¶ added in v0.3.1
SetDB sets the database connection for the Way object. It takes a pointer to a DB object as a parameter and assigns it to the db field of the Way object.
func (*Way) SetDBConnection ¶ added in v0.3.1
SetDBConnection sets a new database connection with the given driver.
func (*Way) SetListener ¶ added in v0.3.1
SetListener sets the network listener.
func (*Way) SetSession ¶ added in v0.3.1
SetSession sets the session.
func (*Way) Use ¶ added in v0.1.0
func (w *Way) Use(middleware ...MiddlewareFunc)
Use adds a middleware to the middleware stack.
