Documentation ¶
Index ¶
- Constants
- Variables
- func ActionInvoker(c *Controller)
- func I18nFilter(c *Controller)
- func ParamsFilter(c *Controller)
- func RouterFilter(c *Controller)
- func SessionFilter(c *Controller)
- type AcceptLanguage
- type Config
- type Controller
- func (c *Controller) Redirect(url string)
- func (c *Controller) Render(args ...interface{})
- func (c *Controller) RenderError(status int, msg string)
- func (c *Controller) RenderJson(obj interface{})
- func (c *Controller) RenderJsonIndent(obj interface{}, indent string)
- func (c *Controller) RenderString(body string)
- func (c *Controller) Translate(msg string, args ...interface{}) string
- func (c *Controller) UrlBase(path string) string
- func (c *Controller) UrlModuleBase(path string) string
- type Filter
- type Module
- type Params
- type Request
- type Response
- type Route
- type Service
- func (s *Service) Error() error
- func (s *Service) HandlerFuncRegister(baseuri string, h http.HandlerFunc)
- func (s *Service) HandlerRegister(baseuri string, h http.Handler)
- func (s *Service) ModuleRegister(baseuri string, mod Module)
- func (s *Service) RpcRegister(baseuri string, rcvr interface{})
- func (s *Service) Start() error
- func (s *Service) Stop() error
- type Session
- type TemplateLoader
- type WebSocket
Constants ¶
View Source
const ( RouteTypeBasic = "basic" RouteTypeStatic = "static" )
View Source
const Version = "0.11.0"
Variables ¶
View Source
var DefaultFilters = []Filter{ RouterFilter, ParamsFilter, SessionFilter, I18nFilter, ActionInvoker, }
Filters is the default set of global filters. It may be set by the application on initialization.
View Source
var ( DefaultModule = Module{ // contains filtered or unexported fields } )
View Source
var (
GlobalService = NewService()
)
View Source
var TemplateFuncs = map[string]interface{}{ "eq": tfEqual, "raw": func(text string) template.HTML { return template.HTML(text) }, "replace": func(s, old, new string) string { return strings.Replace(s, old, new, -1) }, "date": func(t time.Time) string { return t.Format("2006-01-02") }, "datetime": func(t time.Time) string { return t.Format("2006-01-02 15:04") }, "upper": func(s string) string { return strings.ToUpper(s) }, "lower": func(s string) string { return strings.ToLower(s) }, "T": func(lang map[string]interface{}, msg string, args ...interface{}) string { return i18nTranslate(lang["LANG"].(string), msg, args...) }, }
Functions ¶
func ActionInvoker ¶
func ActionInvoker(c *Controller)
func I18nFilter ¶
func I18nFilter(c *Controller)
func ParamsFilter ¶
func ParamsFilter(c *Controller)
func RouterFilter ¶
func RouterFilter(c *Controller)
func SessionFilter ¶
func SessionFilter(c *Controller)
Types ¶
type AcceptLanguage ¶
A single language from the Accept-Language HTTP header.
type Config ¶
type Config struct { HttpAddr string `json:"http_addr,omitempty" toml:"http_addr,omitempty"` // e.g. "127.0.0.1", "unix:/tmp/app.sock" HttpPort uint16 `json:"http_port,omitempty" toml:"http_port,omitempty"` // e.g. 8080 HttpTimeout uint16 `json:"http_timeout,omitempty" toml:"http_timeout,omitempty"` UrlBasePath string `json:"url_base_path,omitempty" toml:"url_base_path,omitempty"` CookieKeyLocale string `json:"cookie_key_locale,omitempty" toml:"cookie_key_locale,omitempty"` CookieKeySession string `json:"cookie_key_session,omitempty" toml:"cookie_key_session,omitempty"` CompressResponse bool `json:"compress_response,omitempty" toml:"compress_response,omitempty"` }
func (*Config) TemplateFuncRegister ¶
type Controller ¶
type Controller struct { Name string // The controller name, e.g. "App" ActionName string // The action name, e.g. "Index" Request *Request Response *Response Params *Params // Parameters from URL and form (including multipart). Session *Session // Session, stored in cookie, signed. AutoRender bool Data map[string]interface{} // contains filtered or unexported fields }
func NewController ¶
func NewController(srv *Service, req *Request, resp *Response) *Controller
func (*Controller) Redirect ¶
func (c *Controller) Redirect(url string)
func (*Controller) Render ¶
func (c *Controller) Render(args ...interface{})
func (*Controller) RenderError ¶
func (c *Controller) RenderError(status int, msg string)
func (*Controller) RenderJson ¶
func (c *Controller) RenderJson(obj interface{})
func (*Controller) RenderJsonIndent ¶
func (c *Controller) RenderJsonIndent(obj interface{}, indent string)
func (*Controller) RenderString ¶
func (c *Controller) RenderString(body string)
func (*Controller) Translate ¶
func (c *Controller) Translate(msg string, args ...interface{}) string
func (*Controller) UrlBase ¶
func (c *Controller) UrlBase(path string) string
func (*Controller) UrlModuleBase ¶
func (c *Controller) UrlModuleBase(path string) string
type Filter ¶
type Filter func(c *Controller)
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func NewStaticModule ¶
func (*Module) ControllerRegister ¶
func (m *Module) ControllerRegister(c interface{})
func (*Module) TemplateFileSystemSet ¶
func (m *Module) TemplateFileSystemSet(fss ...http.FileSystem)
func (*Module) TemplatePathSet ¶
type Params ¶
type Request ¶
type Request struct { *http.Request ContentType string AcceptLanguage []AcceptLanguage Locale string RequestPath string UrlPathExtra string RawBody []byte WebSocket *WebSocket }
func NewRequest ¶
func (*Request) JsonDecode ¶
type Response ¶
type Response struct { Status int Out http.ResponseWriter // contains filtered or unexported fields }
func NewResponse ¶
func NewResponse(w http.ResponseWriter) *Response
func (*Response) WriteHeader ¶
type Service ¶
type Service struct { Config Config Filters []Filter TemplateLoader *TemplateLoader // contains filtered or unexported fields }
func NewService ¶
func NewService() *Service
func (*Service) HandlerFuncRegister ¶
func (s *Service) HandlerFuncRegister(baseuri string, h http.HandlerFunc)
func (*Service) ModuleRegister ¶
func (*Service) RpcRegister ¶
type TemplateLoader ¶
type TemplateLoader struct {
// contains filtered or unexported fields
}
This object handles loading and parsing of templates. Everything below the application's views directory is treated as a template.
func (*TemplateLoader) Clean ¶
func (it *TemplateLoader) Clean(modName string)
func (*TemplateLoader) Render ¶
func (it *TemplateLoader) Render(wr io.Writer, modName, tplPath string, arg interface{}) error
func (*TemplateLoader) Set ¶
func (it *TemplateLoader) Set(modName string, viewpaths []string, viewfss []http.FileSystem)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
deps
|
|
go.net/websocket
Package websocket implements a client and server for the WebSocket protocol as specified in RFC 6455.
|
Package websocket implements a client and server for the WebSocket protocol as specified in RFC 6455. |
Click to show internal directories.
Click to hide internal directories.