Documentation
¶
Index ¶
- func Serve(config Config)
- type AutoTLSConfig
- type CORSHeaders
- type Config
- type Context
- func (ctx *Context) AddHeader(key string, value string)
- func (ctx *Context) BasicUser() acl.BasicUser
- func (ctx *Context) End(status int, a ...string)
- func (ctx *Context) Error(err error)
- func (ctx *Context) File(filepath string)
- func (ctx *Context) FormArray(key string) (a []string)
- func (ctx *Context) FormBool(key string, defaultValue bool) bool
- func (ctx *Context) FormFloat(key string, defaultValue float64) float64
- func (ctx *Context) FormInt(key string, defaultValue int64) int64
- func (ctx *Context) FormString(key string, defaultValue string) string
- func (ctx *Context) GetCookie(name string) (cookie *http.Cookie, err error)
- func (ctx *Context) Html(html string)
- func (ctx *Context) IfModified(modtime time.Time, then func())
- func (ctx *Context) Json(status int, v interface{})
- func (ctx *Context) MustUser() acl.User
- func (ctx *Context) Next()
- func (ctx *Context) Ok(text string)
- func (ctx *Context) ParseMultipartForm(maxMemoryBytes int64)
- func (ctx *Context) Redirect(status int, url string)
- func (ctx *Context) RemoteIP() string
- func (ctx *Context) RemoveCookie(cookie *http.Cookie)
- func (ctx *Context) Session() (sess session.Session)
- func (ctx *Context) SetCookie(cookie *http.Cookie)
- func (ctx *Context) SetHeader(key string, value string)
- func (ctx *Context) SetUser(user acl.User)
- func (ctx *Context) User() acl.User
- func (ctx *Context) Write(p []byte) (n int, err error)
- func (ctx *Context) WriteString(s string) (n int, err error)
- func (ctx *Context) Zip(path string)
- type HTTPSConfig
- type Mux
- type REST
- func (s *REST) Delete(endpoint string, handles ...RESTHandle)
- func (s *REST) Get(endpoint string, handles ...RESTHandle)
- func (s *REST) Handle(method string, endpoint string, handles []RESTHandle)
- func (s *REST) Head(endpoint string, handles ...RESTHandle)
- func (s *REST) Options(endpoint string, handles ...RESTHandle)
- func (s *REST) Patch(endpoint string, handles ...RESTHandle)
- func (s *REST) Post(endpoint string, handles ...RESTHandle)
- func (s *REST) Put(endpoint string, handles ...RESTHandle)
- func (s *REST) Use(middlewares ...RESTHandle)
- type RESTHandle
- type ResponseWriter
- type State
- type URL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutoTLSConfig ¶ added in v0.4.0
type CORSHeaders ¶ added in v0.4.0
type CORSHeaders struct {
AllowOrigin string
AllowMethods []string
AllowHeaders []string
AllowCredentials bool
MaxAge int // in seconds
}
func PublicCORS ¶
func PublicCORS() *CORSHeaders
func (*CORSHeaders) Apply ¶ added in v0.4.0
func (cors *CORSHeaders) Apply(w http.ResponseWriter)
type Config ¶
type Config struct {
Debug bool `json:"debug"`
Port uint16 `json:"port"`
HTTPS HTTPSConfig `json:"https"`
Root string `json:"root"`
ServerName string `json:"serverName"`
CustomHTTPHeaders map[string]string `json:"customHTTPHeaders"`
SessionCookieName string `json:"sessionCookieName"`
HostRedirectRule string `json:"hostRedirectRule"`
ReadTimeout uint32 `json:"readTimeout"`
WriteTimeout uint32 `json:"writeTimeout"`
MaxHeaderBytes uint32 `json:"maxHeaderBytes"`
NotFoundHandler http.Handler `json:"-"`
SessionManager session.Manager `json:"-"`
Logger *log.Logger `json:"-"`
AccessLogger *log.Logger `json:"-"`
}
type Context ¶
type Context struct {
W http.ResponseWriter
R *http.Request
URL *URL
State *State
// contains filtered or unexported fields
}
func (*Context) IfModified ¶ added in v0.2.1
func (*Context) ParseMultipartForm ¶
func (*Context) RemoveCookie ¶
type HTTPSConfig ¶ added in v0.3.0
type HTTPSConfig struct {
Port uint16 `json:"port"`
CertFile string `json:"certFile"`
KeyFile string `json:"keyFile"`
AutoTLS AutoTLSConfig `json:"autotls"`
}
type Mux ¶
type Mux struct {
Config
// contains filtered or unexported fields
}
Mux is a HTTP request multiplexer. The inner router provides by github.com/julienschmidt/httprouter.
func (*Mux) RegisterREST ¶ added in v0.4.0
RegisterREST registers a REST instacce
type REST ¶ added in v0.4.0
func (*REST) Delete ¶ added in v0.4.0
func (s *REST) Delete(endpoint string, handles ...RESTHandle)
func (*REST) Get ¶ added in v0.4.0
func (s *REST) Get(endpoint string, handles ...RESTHandle)
func (*REST) Handle ¶ added in v0.4.0
func (s *REST) Handle(method string, endpoint string, handles []RESTHandle)
func (*REST) Head ¶ added in v0.4.0
func (s *REST) Head(endpoint string, handles ...RESTHandle)
func (*REST) Options ¶ added in v0.4.0
func (s *REST) Options(endpoint string, handles ...RESTHandle)
func (*REST) Patch ¶ added in v0.4.0
func (s *REST) Patch(endpoint string, handles ...RESTHandle)
func (*REST) Post ¶ added in v0.4.0
func (s *REST) Post(endpoint string, handles ...RESTHandle)
func (*REST) Put ¶ added in v0.4.0
func (s *REST) Put(endpoint string, handles ...RESTHandle)
func (*REST) Use ¶ added in v0.4.0
func (s *REST) Use(middlewares ...RESTHandle)
type RESTHandle ¶ added in v0.4.0
type RESTHandle func(ctx *Context)
func CORS ¶
func CORS(cors *CORSHeaders) RESTHandle
func SetPrivileges ¶ added in v0.4.0
func SetPrivileges(privileges ...string) RESTHandle
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
A ResponseWriter is used by an rex mux to construct an HTTP response.
func (*ResponseWriter) Header ¶
func (w *ResponseWriter) Header() http.Header
Header returns the header map that will be sent by WriteHeader.
func (*ResponseWriter) Hijack ¶ added in v0.2.3
func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack lets the caller take over the connection.
func (*ResponseWriter) Write ¶
func (w *ResponseWriter) Write(p []byte) (n int, err error)
Write writes the data to the connection as part of an HTTP reply.
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(status int)
WriteHeader sends an HTTP response header with the provided status code.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.