Documentation
¶
Index ¶
- func Delete(path string, handles ...Handle)
- func Get(path string, handles ...Handle)
- func Group(prefix string, callback func(*REST))
- func Head(path string, handles ...Handle)
- func NotFound(handle Handle)
- func Options(path string, handles ...Handle)
- func Patch(path string, handles ...Handle)
- func Post(path string, handles ...Handle)
- func Put(path string, handles ...Handle)
- func Serve(config Config)
- func Start(port uint16)
- func StartAutoTLS(port uint16, hosts ...string)
- func StartTLS(port uint16, certFile string, keyFile string)
- func Trace(path string, handles ...Handle)
- func Use(middlewares ...Handle)
- type ACLUser
- type AutoTLSConfig
- type BasicUser
- type CORSOptions
- type Config
- type Context
- func (ctx *Context) ACLUser() ACLUser
- func (ctx *Context) AddHeader(key string, value string)
- func (ctx *Context) BasicUser() BasicUser
- func (ctx *Context) End(status int, a ...string)
- func (ctx *Context) Error(err error)
- func (ctx *Context) File(filename string)
- func (ctx *Context) FormFile(key string) (multipart.File, *multipart.FileHeader, error)
- func (ctx *Context) FormValue(key string, defaultValue ...string) FormValue
- func (ctx *Context) FormValues(key string) (a []string)
- func (ctx *Context) GetCookie(name string) (cookie *http.Cookie, err error)
- func (ctx *Context) GetHeader(key string) string
- func (ctx *Context) HTML(html string)
- func (ctx *Context) IfModified(modtime time.Time, then func())
- func (ctx *Context) IfNotMatch(etag string, then func())
- func (ctx *Context) JSON(v interface{})
- func (ctx *Context) JSONError(err error)
- func (ctx *Context) Next()
- func (ctx *Context) Ok(text string)
- func (ctx *Context) ParseMultipartForm(maxMemoryBytes int64)
- func (ctx *Context) Redirect(url string, status int)
- func (ctx *Context) RemoteIP() string
- func (ctx *Context) RemoveCookie(cookie *http.Cookie)
- func (ctx *Context) RemoveCookieByName(name string)
- func (ctx *Context) Render(template Template, data interface{})
- func (ctx *Context) RenderHTML(html string, data interface{})
- func (ctx *Context) Session() *ContextSession
- func (ctx *Context) SetACLUser(user ACLUser)
- func (ctx *Context) SetCookie(cookie *http.Cookie)
- func (ctx *Context) SetHeader(key string, value string)
- func (ctx *Context) StoreValue(key string, value interface{})
- func (ctx *Context) Value(key string) (value interface{}, ok bool)
- func (ctx *Context) Zip(path string)
- type ContextSession
- type FormValue
- type Handle
- func ACL(permissions ...string) Handle
- func BasicAuth(authFunc func(name string, password string) (ok bool, err error)) Handle
- func BasicAuthWithRealm(realm string, authFunc func(name string, password string) (ok bool, err error)) Handle
- func CORS(opts CORSOptions) Handle
- func Header(key string, value string) Handle
- func SessionPool(pool session.Pool) Handle
- func SessionSIDStore(sidStore session.SIDStore) Handle
- func Static(root string, fallbackPath ...string) Handle
- type InvalidError
- type Logger
- type REST
- func (rest *REST) Delete(path string, handles ...Handle)
- func (rest *REST) Get(path string, handles ...Handle)
- func (rest *REST) Group(prefix string, callback func(*REST))
- func (rest *REST) Handle(method string, path string, handles ...Handle)
- func (rest *REST) Head(path string, handles ...Handle)
- func (rest *REST) Host(host string) *REST
- func (rest *REST) NotFound(handle Handle)
- func (rest *REST) Options(path string, handles ...Handle)
- func (rest *REST) Patch(path string, handles ...Handle)
- func (rest *REST) Post(path string, handles ...Handle)
- func (rest *REST) Prefix(prefix string) *REST
- func (rest *REST) Put(path string, handles ...Handle)
- func (rest *REST) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (rest *REST) Trace(path string, handles ...Handle)
- func (rest *REST) Use(middlewares ...Handle)
- type TLSConfig
- type Template
- type URL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NotFound ¶ added in v0.9.0
func NotFound(handle Handle)
NotFound handles the requests that are not routed
func StartAutoTLS ¶ added in v0.9.0
StartAutoTLS starts an HTTPS server using autocert with Let's Encrypto SSL
Types ¶
type ACLUser ¶ added in v0.8.1
type ACLUser interface {
Permissions() []string
}
A ACLUser contains a Permissions method that returns the acl permission id list
type AutoTLSConfig ¶ added in v0.4.0
type AutoTLSConfig struct {
AcceptTOS bool `json:"acceptTOS"`
Hosts []string `json:"hosts"`
CacheDir string `json:"cacheDir"`
Cache autocert.Cache `json:"-"`
}
AutoTLSConfig contains the options to support autocert by Let's Encrypto SSL.
type BasicUser ¶ added in v0.8.1
BasicUser represents a http Basic-Auth user that contains the username and password
type CORSOptions ¶ added in v0.5.0
type CORSOptions struct {
AllowOrigin string
AllowMethods []string
AllowHeaders []string
ExposeHeaders []string
AllowCredentials bool
MaxAge int // in seconds
}
CORSOptions contains the options to CORS.
type Config ¶
type Config struct {
Port uint16 `json:"port"`
TLS TLSConfig `json:"tls"`
ReadTimeout uint32 `json:"readTimeout"`
WriteTimeout uint32 `json:"writeTimeout"`
MaxHeaderBytes uint32 `json:"maxHeaderBytes"`
Logger Logger `json:"-"`
AccessLogger Logger `json:"-"`
}
Config contains the options to run REX server.
type Context ¶
type Context struct {
W http.ResponseWriter
R *http.Request
URL *URL
// contains filtered or unexported fields
}
func (*Context) FormValues ¶
func (*Context) IfModified ¶ added in v0.2.1
func (*Context) IfNotMatch ¶ added in v0.5.0
func (*Context) ParseMultipartForm ¶
func (*Context) RemoveCookie ¶
func (*Context) RemoveCookieByName ¶ added in v0.8.0
func (*Context) RenderHTML ¶ added in v0.5.8
func (*Context) Session ¶
func (ctx *Context) Session() *ContextSession
func (*Context) SetACLUser ¶ added in v0.9.2
func (*Context) StoreValue ¶ added in v0.9.2
type ContextSession ¶ added in v0.6.1
type ContextSession struct {
// contains filtered or unexported fields
}
func (*ContextSession) Delete ¶ added in v0.6.1
func (s *ContextSession) Delete(key string)
func (*ContextSession) Flush ¶ added in v0.6.1
func (s *ContextSession) Flush()
func (*ContextSession) Get ¶ added in v0.6.1
func (s *ContextSession) Get(key string) interface{}
func (*ContextSession) Has ¶ added in v0.6.1
func (s *ContextSession) Has(key string) bool
func (*ContextSession) SID ¶ added in v0.6.1
func (s *ContextSession) SID() string
func (*ContextSession) Set ¶ added in v0.6.1
func (s *ContextSession) Set(key string, value interface{})
type Handle ¶ added in v0.8.0
type Handle func(ctx *Context)
Handle defines a function to handle route requests.
func BasicAuthWithRealm ¶ added in v0.8.0
func BasicAuthWithRealm(realm string, authFunc func(name string, password string) (ok bool, err error)) Handle
BasicAuthWithRealm returns a Basic HTTP Authorization middleware with realm.
func SessionPool ¶ added in v0.9.4
SessionPool returns a SessionPool middleware.
func SessionSIDStore ¶ added in v0.6.1
SessionSIDStore returns a SessionSIDStore middleware.
type InvalidError ¶ added in v0.7.4
InvalidError is an error with code
func Invalid ¶ added in v0.7.4
func Invalid(code int, message string) *InvalidError
Invalid returns a new InvalidError
func (*InvalidError) Error ¶ added in v0.7.4
func (err *InvalidError) Error() string
Error implements the error type
type Logger ¶ added in v0.5.0
type Logger interface {
Println(v ...interface{})
Printf(format string, v ...interface{})
}
Logger is a Logger contains Println and Printf methods
type REST ¶ added in v0.4.0
type REST struct {
// Logger to log requests
AccessLogger Logger
// Logger to log errors
Logger Logger
// If enabled, errors will be sent to the client/browser,
// this should be disable in production.
SendError bool
// contains filtered or unexported fields
}
REST is a http Handler which contains the router, middlewares and configuration settings
func (*REST) Handle ¶ added in v0.4.0
Handle registers a new request handle with the given method and path.
func (*REST) Options ¶ added in v0.4.0
Options is a shortcut for rest.Handle("OPTIONS", path, handles)
func (*REST) ServeHTTP ¶ added in v0.5.0
func (rest *REST) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http Handler interface.
type TLSConfig ¶ added in v0.9.0
type TLSConfig struct {
Port uint16 `json:"port"`
CertFile string `json:"certFile"`
KeyFile string `json:"keyFile"`
AutoTLS AutoTLSConfig `json:"autotls"`
AutoRedirect bool `json:"autoRedirect"`
}
TLSConfig contains the options to support https.