Documentation
¶
Index ¶
- Constants
- func RegisterValidate(af AutoValidateFunction)
- func TypeOfEmpty() interface{}
- func TypeOfMap() interface{}
- type AbstractDispatcher
- func (this *AbstractDispatcher) AddController(domain string, name string, url string, control Controller)
- func (this *AbstractDispatcher) AddInterceptor(ins ...Interceptor)
- func (this *AbstractDispatcher) AddRequestMapper(r *RequestMapper)
- func (this *AbstractDispatcher) AddRequestMapperByHandleFunction(name string, url []string, input interface{}, handle HandleFunction, ...)
- func (this *AbstractDispatcher) AddRequestMapperBystruct(target interface{})
- func (this *AbstractDispatcher) ConfigPort(p int)
- func (this *AbstractDispatcher) ConfigStatic(root string)
- func (this *AbstractDispatcher) ConfigTemplate(root string, suffix string)
- func (this *AbstractDispatcher) ExecuteRequest(r Controller, writer io.Writer, context HttpContext, ...) StyleType
- func (this *AbstractDispatcher) HandlePainc(after func(v interface{}))
- func (this *AbstractDispatcher) MatchUrl(u string) (Controller, Params)
- func (this *AbstractDispatcher) ProcessStaticUrl(url string, writer io.Writer) (string, error)
- func (this *AbstractDispatcher) SetDispatchManager(d *DispatchManager)
- func (this *AbstractDispatcher) SetSessionManager(s *SessionManager)
- type AutoValidateFunction
- type BingoError
- type CMap
- type Context
- type Controller
- type Convertor
- type CookieFace
- type CookieKey
- type DispatchManager
- func (this *DispatchManager) AddApi(domain string, name, url string, handle Handle)
- func (this *DispatchManager) AddRequestMapper(domain string, r *RequestMapper)
- func (this *DispatchManager) GetApi(domain, url string) (Handle, Params)
- func (this *DispatchManager) GetController(domain, url string) (Controller, Params)
- func (this *DispatchManager) GetRequestMapper(domain, url string) *RequestMapper
- func (this *DispatchManager) Init()
- type Error
- type FileContainer
- type FileForm
- type FileHandler
- type Handle
- type HandleFunction
- type HandleMap
- type HttpContext
- type HttpHeaderFace
- type HttpMethodType
- type HttpSession
- type Interceptor
- type ModelView
- type MutiController
- type Param
- type Params
- type RequestMapper
- type SessionManager
- func (this *SessionManager) Create(face CookieFace) *HttpSession
- func (this *SessionManager) DeleteSession(id string)
- func (this *SessionManager) GetSession(face CookieFace) *HttpSession
- func (this *SessionManager) GetSessionById(id string) *HttpSession
- func (this *SessionManager) Init()
- func (this *SessionManager) SetStore(store SessionStore)
- type SessionStore
- type StaticView
- type StyleType
- type TemplateEngine
Constants ¶
View Source
const ( //http方法 Method_GET = "GET" Method_POST = "POST" Method_PUT = "PUT" Method_DELETE = "DELETE" Method_PATCH = "PATCH" Method_HEAD = "HEAD" //返回码 Code_OK = 200 Code_CREATED = 201 Code_EMPTY = 204 Code_NOT_MODIFIED = 304 Code_BAD = 400 Code_UNAUTHORIZED = 401 Code_FORBIDDEN = 403 Code_NOT_FOUND = 404 Code_CONFLICT = 409 Code_ERROR = 500 Code_NOT_IMPLEMENTS = 501 Code_NOT_ALLOWED = 405 CONTENT_TYPE = "Content-Type" )
View Source
const (
Default_Port = 8080
)
Variables ¶
This section is empty.
Functions ¶
func RegisterValidate ¶
func RegisterValidate(af AutoValidateFunction)
func TypeOfEmpty ¶
func TypeOfEmpty() interface{}
Types ¶
type AbstractDispatcher ¶
type AbstractDispatcher struct { Port int // contains filtered or unexported fields }
func (*AbstractDispatcher) AddController ¶
func (this *AbstractDispatcher) AddController(domain string, name string, url string, control Controller)
func (*AbstractDispatcher) AddInterceptor ¶
func (this *AbstractDispatcher) AddInterceptor(ins ...Interceptor)
func (*AbstractDispatcher) AddRequestMapper ¶
func (this *AbstractDispatcher) AddRequestMapper(r *RequestMapper)
func (*AbstractDispatcher) AddRequestMapperByHandleFunction ¶
func (this *AbstractDispatcher) AddRequestMapperByHandleFunction(name string, url []string, input interface{}, handle HandleFunction, methods []HttpMethodType)
func (*AbstractDispatcher) AddRequestMapperBystruct ¶
func (this *AbstractDispatcher) AddRequestMapperBystruct(target interface{})
*
通过mapper 的struct tag标签加入映射
func (*AbstractDispatcher) ConfigPort ¶
func (this *AbstractDispatcher) ConfigPort(p int)
func (*AbstractDispatcher) ConfigStatic ¶
func (this *AbstractDispatcher) ConfigStatic(root string)
func (*AbstractDispatcher) ConfigTemplate ¶
func (this *AbstractDispatcher) ConfigTemplate(root string, suffix string)
func (*AbstractDispatcher) ExecuteRequest ¶
func (this *AbstractDispatcher) ExecuteRequest(r Controller, writer io.Writer, context HttpContext, input func(interface{}) error) StyleType
执行请求
func (*AbstractDispatcher) HandlePainc ¶
func (this *AbstractDispatcher) HandlePainc(after func(v interface{}))
func (*AbstractDispatcher) MatchUrl ¶
func (this *AbstractDispatcher) MatchUrl(u string) (Controller, Params)
func (*AbstractDispatcher) ProcessStaticUrl ¶
func (*AbstractDispatcher) SetDispatchManager ¶
func (this *AbstractDispatcher) SetDispatchManager(d *DispatchManager)
func (*AbstractDispatcher) SetSessionManager ¶
func (this *AbstractDispatcher) SetSessionManager(s *SessionManager)
type AutoValidateFunction ¶
type AutoValidateFunction func(v interface{}) []error
type Controller ¶
type Controller interface { Select(writer io.Writer, input func(interface{}) error) StyleType IsSupportMethod(m HttpMethodType) bool }
控制器
type CookieFace ¶
type CookieFace interface { CookieRead(key string) map[CookieKey]interface{} CookieWrite(key string, value map[CookieKey]interface{}) error }
cookie接口
type DispatchManager ¶
type DispatchManager struct {
// contains filtered or unexported fields
}
*
请求分发管理
func (*DispatchManager) AddApi ¶
func (this *DispatchManager) AddApi(domain string, name, url string, handle Handle)
* 增加单个api的映射
func (*DispatchManager) AddRequestMapper ¶
func (this *DispatchManager) AddRequestMapper(domain string, r *RequestMapper)
*
新增一个requestmapper的映射。
一个requestmapper会对应多个url
func (*DispatchManager) GetApi ¶
func (this *DispatchManager) GetApi(domain, url string) (Handle, Params)
根据域名和url获取对应的API
func (*DispatchManager) GetController ¶
func (this *DispatchManager) GetController(domain, url string) (Controller, Params)
func (*DispatchManager) GetRequestMapper ¶
func (this *DispatchManager) GetRequestMapper(domain, url string) *RequestMapper
func (*DispatchManager) Init ¶
func (this *DispatchManager) Init()
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func CreateError ¶
func CreateErrorF ¶
type FileForm ¶
type FileForm struct { FileName string FileSize int64 IsError bool Error string File FileHandler }
文件表单
type HandleMap ¶
func (HandleMap) Add ¶
func (this HandleMap) Add(name string, handle HandleFunction, p interface{})
type HttpContext ¶
type HttpContext interface { HttpHeaderFace CookieFace }
type HttpHeaderFace ¶
type HttpHeaderFace interface { RequestHeaderRead(key string) string GetRequestURI() string ResponseHeaderwrite(key string, v string) error }
协议头接口
type HttpMethodType ¶
type HttpMethodType byte
const ( Get HttpMethodType = 20 Post HttpMethodType = 21 Put HttpMethodType = 22 Del HttpMethodType = 23 Head HttpMethodType = 24 )
func ParseHttpMethodType ¶
func ParseHttpMethodType(method string) HttpMethodType
func (HttpMethodType) MarshalYAML ¶
func (this HttpMethodType) MarshalYAML() (interface{}, error)
func (*HttpMethodType) UnmarshalYAML ¶
func (this *HttpMethodType) UnmarshalYAML(unmarshal func(interface{}) error) error
type HttpSession ¶
type HttpSession struct {
// contains filtered or unexported fields
}
会话
func (*HttpSession) GetValue ¶
func (this *HttpSession) GetValue(key string) interface{}
func (*HttpSession) ID ¶
func (this *HttpSession) ID() string
func (*HttpSession) IsNew ¶
func (this *HttpSession) IsNew() bool
func (*HttpSession) SetValue ¶
func (this *HttpSession) SetValue(key string, value interface{})
func (*HttpSession) Touch ¶
func (this *HttpSession) Touch()
type Interceptor ¶
type Interceptor interface { PreHandle(writer io.Writer, context HttpContext) bool InputProcess(context HttpContext, input interface{}) error PostHandle(writer io.Writer, context HttpContext, mv *ModelView) BingoError AfterCompletion(writer io.Writer, context HttpContext, err BingoError) BingoError }
type Params ¶
type Params []Param
Params is a Param-slice, as returned by the router. The slice is ordered, the first URL parameter is also the first slice value. It is therefore safe to read values by the index.
type RequestMapper ¶
type RequestMapper struct { Name string //名称 Url []string //url路径 Methods []HttpMethodType //请求参数类型 Request interface{} //返回值处理器 Response Convertor Handle HandleFunction ResponseStyle StyleType }
url元信息描述
func (*RequestMapper) IsSupportMethod ¶
func (this *RequestMapper) IsSupportMethod(m HttpMethodType) bool
type SessionManager ¶
type SessionManager struct { CookieName string //客户端cookie名称 // contains filtered or unexported fields }
func (*SessionManager) Create ¶
func (this *SessionManager) Create(face CookieFace) *HttpSession
func (*SessionManager) DeleteSession ¶
func (this *SessionManager) DeleteSession(id string)
func (*SessionManager) GetSession ¶
func (this *SessionManager) GetSession(face CookieFace) *HttpSession
func (*SessionManager) GetSessionById ¶
func (this *SessionManager) GetSessionById(id string) *HttpSession
func (*SessionManager) Init ¶
func (this *SessionManager) Init()
func (*SessionManager) SetStore ¶
func (this *SessionManager) SetStore(store SessionStore)
type SessionStore ¶
type StaticView ¶
type StaticView struct { Name string //资源名称 Media string //资源类型 Length int //资源长度 Reader FileHandler //资源内容 }
type StyleType ¶
type StyleType byte
数据格式类型
func ParseHttpStyleType ¶
func (StyleType) GetContentType ¶
func (StyleType) MarshalYAML ¶
func (*StyleType) UnmarshalYAML ¶
type TemplateEngine ¶
type TemplateEngine struct { RootPath string //模板根路径 SubTemplatePath string //子模板及片段定义的目录 Suffix string //模板文件后缀 CacheSize int //缓存模板个数 ErrorTemplate string //错误模板 // contains filtered or unexported fields }
func (*TemplateEngine) Init ¶
func (this *TemplateEngine) Init()
func (*TemplateEngine) Render ¶
func (this *TemplateEngine) Render(w io.Writer, templateName string, data interface{}) BingoError
func (*TemplateEngine) WriteError ¶
func (this *TemplateEngine) WriteError(w io.Writer, err BingoError)
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
* SQL生成模板 用于根据struct的定义生成update语句和insert语句 规则 1、表名 默认t_stuct的名称(小写,驼峰转 xx_xx) 可以通过setTablePreFix来指定默认的表前缀 可以通过tag Table:""指定表名 2、字段名称 默认字段名称(小写,驼峰转 xx_xx) 可以通过 tag Field:""指定字段名 3、特例 通过tag Option:"" 来指定。
|
* SQL生成模板 用于根据struct的定义生成update语句和insert语句 规则 1、表名 默认t_stuct的名称(小写,驼峰转 xx_xx) 可以通过setTablePreFix来指定默认的表前缀 可以通过tag Table:""指定表名 2、字段名称 默认字段名称(小写,驼峰转 xx_xx) 可以通过 tag Field:""指定字段名 3、特例 通过tag Option:"" 来指定。 |
Click to show internal directories.
Click to hide internal directories.