Documentation ¶
Index ¶
- Constants
- Variables
- func On(moudle, name string, handler Subscriber)
- func OnFunc(moudle, name string, handler func(*EventContext))
- func RegisterProcessor(name string, p HttpProcessor)
- func RegisterProcessorWith(name string, p HttpProcessor, method, path string)
- type ActionContext
- type ActionSubscriber
- type BundleResult
- type ChanResult
- type CompressProcessor
- type ContentResult
- type ContentTyper
- type Controller
- type DataResult
- type ErrorResult
- type EventContext
- type FileResult
- type FileStreamResult
- type FormatFunc
- type FormatList
- type FuncServer
- func (f *FuncServer) BindByIndex()
- func (f *FuncServer) BindByNames(name ...string)
- func (f *FuncServer) BindToStruct()
- func (f *FuncServer) Execute(ctx *HttpContext)
- func (f *FuncServer) Return(fn FormatFunc) *FuncServer
- func (f *FuncServer) ReturnJson() *FuncServer
- func (f *FuncServer) ReturnXml() *FuncServer
- type GoHtml
- type Handler
- type HtmlOption
- type HttpContext
- func (ctx *HttpContext) Accept() string
- func (ctx *HttpContext) AddHeader(key string, value string)
- func (ctx *HttpContext) ContentType(ctype string)
- func (ctx *HttpContext) Cookie(name string) (*http.Cookie, error)
- func (ctx *HttpContext) Expires(t string)
- func (ctx *HttpContext) FV(name string) string
- func (ctx *HttpContext) Flush()
- func (ctx *HttpContext) FormBool(name string) (bool, bool)
- func (ctx *HttpContext) FormBoolOr(name string, v bool) bool
- func (ctx *HttpContext) FormFloat(name string) (float64, bool)
- func (ctx *HttpContext) FormFloatOr(name string, v float64) float64
- func (ctx *HttpContext) FormInt(name string) (int, bool)
- func (ctx *HttpContext) FormIntOr(name string, v int) int
- func (ctx *HttpContext) FormValue(name string) string
- func (ctx *HttpContext) GetFlash(key string) (v interface{}, ok bool)
- func (ctx *HttpContext) ReadBody() ([]byte, error)
- func (ctx *HttpContext) ReqHeader(name string) string
- func (ctx *HttpContext) ResHeader(name string) string
- func (ctx *HttpContext) RouteValue(name string) (string, bool)
- func (ctx *HttpContext) SessionId() string
- func (ctx *HttpContext) SetCookie(cookie *http.Cookie)
- func (ctx *HttpContext) SetFlash(key string, v interface{})
- func (ctx *HttpContext) SetHeader(key string, value string)
- func (ctx *HttpContext) Status(code int)
- func (ctx *HttpContext) String() string
- func (ctx *HttpContext) Write(b []byte) (int, error)
- type HttpProcessor
- type HttpResult
- type HttpServer
- func (srv *HttpServer) Fire(moudle, name string, source, data interface{}, context *HttpContext)
- func (srv *HttpServer) InnerServer() *http.Server
- func (srv *HttpServer) MapPath(file string) string
- func (srv *HttpServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (srv *HttpServer) Setup() (err error)
- func (srv *HttpServer) Start() (err error)
- type JsonResult
- type JsonpResult
- type NotFoundResult
- type NotModifiedResult
- type Process
- type ProcessTable
- type RedirectResult
- type Render
- type RenderProcessor
- type RouteData
- func (r RouteData) Bool(name string) (bool, bool)
- func (r RouteData) BoolOr(name string, v bool) bool
- func (r RouteData) Float(name string) (float64, bool)
- func (r RouteData) FloatOr(name string, v float64) float64
- func (r RouteData) Int(name string) (int, bool)
- func (r RouteData) IntOr(name string, v int) int
- func (r RouteData) Str(name string) (string, bool)
- func (r RouteData) StrOr(name string, v string) string
- type RouteFunc
- type RouteProcessor
- type RouteRule
- func (r *RouteRule) HandleBy(handler Handler)
- func (r *RouteRule) Match(ctx *HttpContext) (data RouteData, ok bool)
- func (r *RouteRule) String() string
- func (r *RouteRule) To(handler func(*HttpContext) (HttpResult, error))
- func (r *RouteRule) ToController(controller interface{}) *Controller
- func (r *RouteRule) ToFunc(function interface{}) *FuncServer
- type RouteTable
- func (r *RouteTable) Delete(path string) *RouteRule
- func (r *RouteTable) Get(path string) *RouteRule
- func (r *RouteTable) Match(ctx *HttpContext) (rule *RouteRule, data map[string]string, ok bool)
- func (r *RouteTable) Path(path string) *RouteRule
- func (r *RouteTable) Post(path string) *RouteRule
- func (r *RouteTable) Put(path string) *RouteRule
- func (r *RouteTable) Regexp(method, path string) *RouteRule
- type Session
- func (s Session) Abandon() error
- func (s Session) Add(key string, value interface{}) (bool, error)
- func (s Session) Get(key string) (interface{}, bool, error)
- func (s Session) Keys() ([]string, error)
- func (s Session) Remove(key string) error
- func (s Session) Set(key string, value interface{}) error
- type StaticProcessor
- type Subscriber
- type SubscriberFunc
- type SubscriberItem
- type TextResult
- type ViewData
- type ViewEngine
- type ViewResult
- type VoidResult
- type WebConfig
- type XmlResult
Constants ¶
const ( HttpVerbsGet = "GET" HttpVerbsPost = "POST" HttpVerbsPut = "PUT" HttpVerbsDelete = "DELETE" HttpVerbsHead = "HEAD" HttpVerbsTrace = "TRACE" HttpVerbsConnect = "CONNECT" HttpVerbsOptions = "OPTIONS" )
const ( HeaderAccept = "Accept" HeaderAcceptCharset = "Accept-Charset" HeaderAcceptEncoding = "Accept-Encoding" HeaderCacheControl = "Cache-Control" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderDate = "Date" HeaderEtag = "Etag" HeaderExpires = "Expires" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderPragma = "Pragma" HeaderServer = "Server" HeaderSetCookie = "Set-Cookie" HeaderUserAgent = "User-Agent" )
const ( ContentTypeStream = "application/octet-stream" ContentTypeJson = "application/json" ContentTypeJsonp = "application/jsonp" ContentTypeJavascript = "application/javascript" ContentTypeHTML = "text/html" ContentTypeXml = "text/xml" ContentTypeCss = "text/css" ContentTypeText = "text/plain" ContentTypeGif = "image/gif" ContentTypeIcon = "image/x-icon" ContentTypeJpeg = "image/jpeg" ContentTypePng = "image/png" )
const ( LogError = iota LogInfo LogDebug )
Variables ¶
var ( // logger Logger *log.Logger // LogLevel is level of log LogLevel int = LogError // EnableProfile mean enable http profile or not EnableProfile bool = false )
var SessionDriver session.Driver
var (
Subscribers []*SubscriberItem
)
var (
TemplateFuncs template.FuncMap = make(map[string]interface{})
)
Functions ¶
func OnFunc ¶
func OnFunc(moudle, name string, handler func(*EventContext))
On register event lister
func RegisterProcessor ¶
func RegisterProcessor(name string, p HttpProcessor)
RegisterProcessor append a HttpProcessor to global ProcessTable
func RegisterProcessorWith ¶
func RegisterProcessorWith(name string, p HttpProcessor, method, path string)
RegisterProcessorWith append a HttpProcessor to global ProcessTable, with field method and path
Types ¶
type ActionContext ¶
type ActionContext struct { // Name is action method name Name string Context *HttpContext Controller reflect.Value Result HttpResult Err error }
ActionContext is data that pass to ActionSubscriber
type ActionSubscriber ¶
type ActionSubscriber interface { OnActionExecuting(action *ActionContext) OnActionExecuted(action *ActionContext) OnException(action *ActionContext) }
ActionSubscriber is interface that subscrib controller events
type BundleResult ¶
type BundleResult struct {
Files []string
}
BundleResult is bundle of Files
func (*BundleResult) Execute ¶
func (b *BundleResult) Execute(ctx *HttpContext) error
Execute write content of files to HttpContext.Response
func (*BundleResult) Type ¶
func (b *BundleResult) Type() string
ContentType return mime type of BundleResult.Files[0]
type ChanResult ¶
type ChanResult struct { Wait sync.WaitGroup Chan chan string ContentType string Start []byte End []byte Timeout time.Duration }
ChanResult read from a chan string, then write to response
func (*ChanResult) Execute ¶
func (c *ChanResult) Execute(ctx *HttpContext) error
Execute read from Chan then write to Response, until Wait done
type CompressProcessor ¶
CompressProcessor compress http response with gzip/deflate TODO: filter by MimeType?
func (*CompressProcessor) Execute ¶
func (cp *CompressProcessor) Execute(ctx *HttpContext)
Execute convert ctx.Response to compressResponseWriter
func (*CompressProcessor) Register ¶
func (cp *CompressProcessor) Register(server *HttpServer)
Register initialize CompressProcessor
type ContentResult ¶
type ContentResult struct { // ContentType ContentType string // Data Data interface{} }
ContentResult is raw content
func Content ¶
func Content(data interface{}, contentType string) *ContentResult
Content return *ContentResult
func (*ContentResult) Execute ¶
func (c *ContentResult) Execute(ctx *HttpContext) error
Execute write Data to response
type ContentTyper ¶
type ContentTyper interface {
Type() string
}
type Controller ¶
type Controller struct { // Handler Handler reflect.Value //Methods is cache of method reflect info Methods map[string]*gotype.MethodInfo // contains filtered or unexported fields }
Controller is wrap of controller handler
func (*Controller) Execute ¶
func (c *Controller) Execute(ctx *HttpContext)
Execute call action method
type DataResult ¶
type DataResult struct {
// Data
Data interface{}
}
DataResult is wrap of simple type
func (*DataResult) Execute ¶
func (c *DataResult) Execute(ctx *HttpContext) error
Execute write Data to response
type ErrorResult ¶
ErrorResult return error to client
func (*ErrorResult) Execute ¶
func (e *ErrorResult) Execute(ctx *HttpContext) error
Execute write response
type EventContext ¶
type EventContext struct { Moudle string Name string Source interface{} Data interface{} Context *HttpContext }
EventContext is the data pass to Subscriber
type FileResult ¶
type FileResult struct {
Path string
}
FileResult is wrap of static file
func (*FileResult) Execute ¶
func (file *FileResult) Execute(ctx *HttpContext) error
Execute replies to the request with the contents of FileResult.Path
func (*FileResult) Type ¶
func (file *FileResult) Type() string
ContentType return mime type of file
type FileStreamResult ¶
type FileStreamResult struct { // ContentType ContentType string DownloadName string ModifyTime time.Time // Data ?Data io.ReadSeeker Data io.Reader }
FileStreamResult
func FileStream ¶
func FileStream(contentType, downloadName string, reader io.Reader, modtime time.Time) *FileStreamResult
FileStream return *FileStream
func (*FileStreamResult) Execute ¶
func (file *FileStreamResult) Execute(ctx *HttpContext) error
func (*FileStreamResult) Type ¶
func (file *FileStreamResult) Type() string
ContentType return mime type of file
type FormatFunc ¶
type FormatFunc func(*HttpContext, interface{}) (HttpResult, bool)
FormatFunc return formatted HttpResult or return (nil, false) if doesn't format it
type FuncServer ¶
type FuncServer struct { Binder func(*HttpContext) ([]reflect.Value, error) Func interface{} Formatter FormatFunc // contains filtered or unexported fields }
FuncServer is wrap of route handle function
func (*FuncServer) BindByIndex ¶
func (f *FuncServer) BindByIndex()
BindByIndex create function parameters from p1,p2,p3...
func (*FuncServer) BindByNames ¶
func (f *FuncServer) BindByNames(name ...string)
BindByNames create function parameters from name
func (*FuncServer) BindToStruct ¶
func (f *FuncServer) BindToStruct()
BindToStruct create struct parameters
func (*FuncServer) Execute ¶
func (f *FuncServer) Execute(ctx *HttpContext)
Execute call function through reflect
func (*FuncServer) Return ¶
func (f *FuncServer) Return(fn FormatFunc) *FuncServer
Return format result by FormatFunc
func (*FuncServer) ReturnJson ¶
func (f *FuncServer) ReturnJson() *FuncServer
ReturnJson format result as Json
func (*FuncServer) ReturnXml ¶
func (f *FuncServer) ReturnXml() *FuncServer
ReturnXml format result as Xml
type GoHtml ¶
type GoHtml struct { BasePath string EnableCache bool TemplatesCache map[string]*template.Template Funcs template.FuncMap sync.Mutex // contains filtered or unexported fields }
GoHtml is a ViewEngine that wrap "html/template"
func (*GoHtml) Register ¶
func (ve *GoHtml) Register(server *HttpServer) error
Register initialize viewengine
type Handler ¶
type Handler interface {
Execute(ctx *HttpContext)
}
type HtmlOption ¶
type HttpContext ¶
type HttpContext struct { // Server is current http server Server *HttpServer // Request is *http.Request Request *http.Request // Resonse is http.ResponseWriter Resonse http.ResponseWriter // Method is http method Method string // RequestPath is RequestPath string // PhysicalPath is path of static file PhysicalPath string // RouteData RouteData RouteData // ViewData ViewData map[string]interface{} // Result Result HttpResult // Error Error error // Flash is flash variables of request life cycle Flash map[string]interface{} // Session Session Session // SessionIsNew is true if create session in this request SessionIsNew bool }
HttpContext is wrap of request & response
func (*HttpContext) Accept ¶
func (ctx *HttpContext) Accept() string
Accept return request header Accept
func (*HttpContext) AddHeader ¶
func (ctx *HttpContext) AddHeader(key string, value string)
AddHeader add response http header
func (*HttpContext) ContentType ¶
func (ctx *HttpContext) ContentType(ctype string)
ContentType set response header Content-Type
func (*HttpContext) Cookie ¶
func (ctx *HttpContext) Cookie(name string) (*http.Cookie, error)
Cookie return cookie from request
func (*HttpContext) Expires ¶
func (ctx *HttpContext) Expires(t string)
Expires set reponse header Expires
func (*HttpContext) FormBool ¶
func (ctx *HttpContext) FormBool(name string) (bool, bool)
FormBool parse form value as bool
func (*HttpContext) FormBoolOr ¶
func (ctx *HttpContext) FormBoolOr(name string, v bool) bool
FormBoolOr return form value as bool or v
func (*HttpContext) FormFloat ¶
func (ctx *HttpContext) FormFloat(name string) (float64, bool)
FormFloat parse form value as float64
func (*HttpContext) FormFloatOr ¶
func (ctx *HttpContext) FormFloatOr(name string, v float64) float64
FormFloatOr return form value as float64 or v
func (*HttpContext) FormInt ¶
func (ctx *HttpContext) FormInt(name string) (int, bool)
FormInt parse form value as int
func (*HttpContext) FormIntOr ¶
func (ctx *HttpContext) FormIntOr(name string, v int) int
FormIntOr return form value as int or v
func (*HttpContext) FormValue ¶
func (ctx *HttpContext) FormValue(name string) string
FormValue is alias of Request FormValue
func (*HttpContext) GetFlash ¶
func (ctx *HttpContext) GetFlash(key string) (v interface{}, ok bool)
GetFlash return value in Context.Flash
func (*HttpContext) ReadBody ¶
func (ctx *HttpContext) ReadBody() ([]byte, error)
ReadBody read Request.Body
func (*HttpContext) ReqHeader ¶
func (ctx *HttpContext) ReqHeader(name string) string
ReqHeader return request header by name
func (*HttpContext) ResHeader ¶
func (ctx *HttpContext) ResHeader(name string) string
ResHeader return response header by name
func (*HttpContext) RouteValue ¶
func (ctx *HttpContext) RouteValue(name string) (string, bool)
RouteValue return route value by name
func (*HttpContext) SessionId ¶
func (ctx *HttpContext) SessionId() string
SessionId return sessionid of current context
func (*HttpContext) SetCookie ¶
func (ctx *HttpContext) SetCookie(cookie *http.Cookie)
SetCookie set cookie to response
func (*HttpContext) SetFlash ¶
func (ctx *HttpContext) SetFlash(key string, v interface{})
SetFlash set value to Context.Flash
func (*HttpContext) SetHeader ¶
func (ctx *HttpContext) SetHeader(key string, value string)
SetHeader set resonse http header
func (*HttpContext) Status ¶
func (ctx *HttpContext) Status(code int)
Status write status code to http header
type HttpProcessor ¶
type HttpProcessor interface { // Execute handle request Execute(ctx *HttpContext) // Register is called once when create a new HttpServer Register(server *HttpServer) }
HttpProcessor is interface that handle http request
type HttpResult ¶
type HttpResult interface { // Execute Execute(ctx *HttpContext) error }
HttpResult is a interface that define how to write server reply to response
type HttpServer ¶
type HttpServer struct { // config Config *WebConfig // net.Listener Listener net.Listener // Processes Processes ProcessTable // RouteTable RouteTable *RouteTable //server variables Variables map[string]interface{} // ViewEngine ViewEngine ViewEngine // contains filtered or unexported fields }
HttpServer
func NewDefaultServer ¶
func NewDefaultServer() (srv *HttpServer, err error)
DefaultServer return a http server with default config
func NewHttpServer ¶
func NewHttpServer(config *WebConfig) (srv *HttpServer, err error)
NewHttpServer return a http server with provided config
func (*HttpServer) Fire ¶
func (srv *HttpServer) Fire(moudle, name string, source, data interface{}, context *HttpContext)
Fire can fire a event
func (*HttpServer) InnerServer ¶
func (srv *HttpServer) InnerServer() *http.Server
InnerServer return inner embedded *http.Server
func (*HttpServer) MapPath ¶
func (srv *HttpServer) MapPath(file string) string
MapPath return physical path
func (*HttpServer) ServeHTTP ¶
func (srv *HttpServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP
func (*HttpServer) Setup ¶
func (srv *HttpServer) Setup() (err error)
Setup initialize server instance
func (*HttpServer) Start ¶
func (srv *HttpServer) Start() (err error)
Start start server instance and listent request
type JsonResult ¶
type JsonResult struct { NeedIndent bool Data interface{} // contains filtered or unexported fields }
JsonResult marshal data and write to response ContentType is "application/json"
func (*JsonResult) Execute ¶
func (j *JsonResult) Execute(ctx *HttpContext) error
Execute encode result as json and write to response
type JsonpResult ¶
type JsonpResult struct {
Data interface{}
}
JsonpResult
func (*JsonpResult) Execute ¶
func (j *JsonpResult) Execute(ctx *HttpContext) error
Execute Content-Type is application/javascript
type NotFoundResult ¶
type NotFoundResult struct { }
NotFoundResult is wrap of http 404
func (*NotFoundResult) Execute ¶
func (r *NotFoundResult) Execute(ctx *HttpContext) error
Execute return 404 to client
type NotModifiedResult ¶
type NotModifiedResult struct { }
NotModifiedResult is wrap of http.StatusNotModified
func (*NotModifiedResult) Execute ¶
func (r *NotModifiedResult) Execute(ctx *HttpContext) error
Execute
type Process ¶
type Process struct { // Name Name string // Path is url to match, / or empty to match all // change to regex? containers muti ? Path string // Method is http method to match, * or empty to match all Method string // Handler is the HttpProcessor Handler HttpProcessor }
Process is wrap of HttpProcessor
func NewCompressProcess ¶
NewCompressProcess return a *Process that wrap CompressProcessor
type ProcessTable ¶
type ProcessTable []*Process
ProcessTable is alias of []*Process
var Processes ProcessTable
Processes is global ProcessTable configration
func (*ProcessTable) Append ¶
func (pt *ProcessTable) Append(p *Process)
Append add a *Process at end
func (*ProcessTable) InsertAfter ¶
func (pt *ProcessTable) InsertAfter(name string, p *Process)
InsertAfter add a *Process after name
func (*ProcessTable) InsertBefore ¶
func (pt *ProcessTable) InsertBefore(name string, p *Process)
InsertBefore add a *Process before name
func (*ProcessTable) Remove ¶
func (pt *ProcessTable) Remove(name string)
Remove delete a *Process from ProcessTable
type RedirectResult ¶
type RedirectResult struct { // Permanent mean redirect permanent or not Permanent bool // UrlStr is the url to redirect UrlStr string }
RedirectResult is wrap of http.StatusMovedPermanently or http.StatusFound
func Redirect ¶
func Redirect(urlStr string, permanent bool) *RedirectResult
func (*RedirectResult) Execute ¶
func (r *RedirectResult) Execute(ctx *HttpContext) error
Execute write status code http.StatusMovedPermanently or http.StatusFound
type RenderProcessor ¶
type RenderProcessor struct {
// contains filtered or unexported fields
}
RenderProcessor render http result
func (*RenderProcessor) Execute ¶
func (p *RenderProcessor) Execute(ctx *HttpContext)
Execute render http result to response
type RouteData ¶
RouteData is wrap of route data
type RouteFunc ¶
type RouteFunc func(*HttpContext) (HttpResult, error)
RouteFunc is wrap of func(*HttpContext) (HttpResult, error)
type RouteProcessor ¶
type RouteProcessor struct {
// contains filtered or unexported fields
}
RouteProcessor route request to handler
func (*RouteProcessor) Execute ¶
func (r *RouteProcessor) Execute(ctx *HttpContext)
Execute find matched RouteRule and call it's Handler
type RouteRule ¶
type RouteRule struct { // Methos is http method of request Method string // Pattern is path pattern Pattern string // Handler process request Handler Handler // contains filtered or unexported fields }
RouteRule is set of route rule & handler
func (*RouteRule) Match ¶
func (r *RouteRule) Match(ctx *HttpContext) (data RouteData, ok bool)
Match return (route data,true) if matched, or (nil, false) if not
func (*RouteRule) To ¶
func (r *RouteRule) To(handler func(*HttpContext) (HttpResult, error))
To route reuqest to a function func(*HttpContext) (HttpResult, error)
func (*RouteRule) ToController ¶
func (r *RouteRule) ToController(controller interface{}) *Controller
ToController route request to an Controller
func (*RouteRule) ToFunc ¶
func (r *RouteRule) ToFunc(function interface{}) *FuncServer
ToFunc route reuqest to a function
type RouteTable ¶
type RouteTable struct {
Routes []*RouteRule
}
RouteTable is collection of RouteRule
func (*RouteTable) Delete ¶
func (r *RouteTable) Delete(path string) *RouteRule
Delete match Delete & path
func (*RouteTable) Match ¶
func (r *RouteTable) Match(ctx *HttpContext) (rule *RouteRule, data map[string]string, ok bool)
Match return matched *RouteRule and route data
func (*RouteTable) Regexp ¶
func (r *RouteTable) Regexp(method, path string) *RouteRule
Regexp match with regexp
type StaticProcessor ¶
type StaticProcessor struct {
// contains filtered or unexported fields
}
StaticProcessor handle request of static file
func (*StaticProcessor) Execute ¶
func (p *StaticProcessor) Execute(ctx *HttpContext)
Execute set FileResult if request file does exist
type Subscriber ¶
type Subscriber interface {
On(e *EventContext)
}
Subscriber is interface of event listener
type SubscriberItem ¶
type SubscriberItem struct { Moudle string Name string Handler Subscriber }
SubscriberItem is wrap of Subscriber
type TextResult ¶
type TextResult string
TextResult is plaintext
func (TextResult) Execute ¶
func (t TextResult) Execute(ctx *HttpContext) error
Execute write Data to response
type ViewEngine ¶
type ViewEngine interface { Register(server *HttpServer) error Execte(writer io.Writer, file string, data interface{}) error }
ViewEngine is wrap of executing template file
type VoidResult ¶
type VoidResult struct { }
VoidResult represents a result that doesn't do anything
type WebConfig ¶
type WebConfig struct { // ServerKey is the identify of server ServerKey string // Address is the address to listen Address string // RootDir is the route directory of web application RootDir string // Timeout is timeout of http handle in second Timeout int // PublicDir is directory of static files PublicDir string // ConfigDir is directory of config files ConfigDir string // ViewDir is base directory of views ViewDir string // AppConfig is app configuration data AppConfig *kson.Node // PluginConfig is configuration data of plugins PluginConfig *kson.Node // ReadTimeout is maximum duration before timing out read of the request, in second ReadTimeout int // WriteTimeout is maximum duration before timing out write of the response, in second WriteTimeout int // MaxHeaderBytes is maximum size of request headers MaxHeaderBytes int // SessionEnable is true if enable session SessionEnable bool // SessionTimeout, session timeout in second SessionTimeout int // SessionDriver is the name of driver SessionDriver string // ViewEnable, enable view engine or not ViewEnable bool // IndexesEnable like Indexes of apache IndexesEnable bool // NotFoundPageEnable NotFoundPageEnable bool // ErrorPageEnable ErrorPageEnable bool // Debug is true if run in debug model Debug bool // contains filtered or unexported fields }
WebConfig is configuration of go web server
func ConfigFromFile ¶
ConfigFromFile parse file and return *WebConfig
func NewDefaultConfig ¶
func NewDefaultConfig() *WebConfig
NewDefaultConfig return *WebConfig with default value
func ReadDefaultConfigFile ¶
ReadDefaultConfigFile parse default config file and return *WebConfig
type XmlResult ¶
type XmlResult struct { Data interface{} NeedIndent bool // contains filtered or unexported fields }
XmlResult marshal data to xml and write to response ContentType: "application/xml"
func (*XmlResult) Execute ¶
func (x *XmlResult) Execute(ctx *HttpContext) error
Execute encode result as xml and write to response
Source Files ¶
- bundle.go
- chan.go
- compress.go
- config.go
- content.go
- context.go
- controller.go
- doc.go
- error.go
- event.go
- file.go
- format.go
- html.go
- json.go
- jsonp.go
- notfound.go
- notmodified.go
- plugin.go
- process.go
- redirect.go
- render.go
- route.go
- server.go
- session.go
- static.go
- utils.go
- view.go
- viewengine.go
- void.go
- websocket.go
- wk.go
- xml.go
Directories ¶
Path | Synopsis |
---|---|
demo
|
|
basic
basic demo`
|
basic demo` |
basic/boot
boot
|
boot |
basic/controller
basic basic basic basic basic demo basic basic session demo basic demo
|
basic basic basic basic basic demo basic basic session demo basic demo |
basic/model
basic demo
|
basic demo |
rest
rest web api demo
|
rest web api demo |
rest/controller
basic basic
|
basic basic |