Documentation ¶
Index ¶
- Variables
- func BytesToString(b []byte) string
- func DebugPrintError(err error)
- func Dir(root string, listDirectory bool) http.FileSystem
- func StringToBytes(s string) (b []byte)
- type AppConfig
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortCode(statusCode int)
- func (c *Context) DecodeJSONBody(v interface{}) error
- func (c *Context) Download(data []byte)
- func (c *Context) Fail(statusCode int, err string)
- func (c *Context) File(filePath string)
- func (c *Context) Form(key string) string
- func (c *Context) GetBool(key string, def ...bool) (bool, error)
- func (c *Context) GetCookie(key string) string
- func (c *Context) GetFile(key string) (multipart.File, *multipart.FileHeader, error)
- func (c *Context) GetFiles(key string) ([]*multipart.FileHeader, error)
- func (c *Context) GetFloat64(key string, def ...float64) (float64, error)
- func (c *Context) GetHeader(key string) string
- func (c *Context) GetIP() (ip string)
- func (c *Context) GetInt(key string, def ...int) (int, error)
- func (c *Context) GetInt16(key string, def ...int16) (int16, error)
- func (c *Context) GetInt32(key string, def ...int32) (int32, error)
- func (c *Context) GetInt64(key string, def ...int64) (int64, error)
- func (c *Context) GetInt8(key string, def ...int8) (int8, error)
- func (c *Context) GetKey(key string) interface{}
- func (c *Context) GetString(key string, def ...string) string
- func (c *Context) GetStrings(key string, def ...[]string) []string
- func (c *Context) GetUint16(key string, def ...uint16) (uint16, error)
- func (c *Context) GetUint32(key string, def ...uint32) (uint32, error)
- func (c *Context) GetUint64(key string, def ...uint64) (uint64, error)
- func (c *Context) GetUint8(key string, def ...uint8) (uint8, error)
- func (c *Context) HTML(name string, data interface{})
- func (c *Context) HandlerName() string
- func (c *Context) IsAjax() bool
- func (c *Context) JSON(v interface{})
- func (c *Context) Next()
- func (c *Context) Param(name string) string
- func (c *Context) Query(key string) string
- func (c *Context) Redirect(statusCode int, url string)
- func (c *Context) Referer() string
- func (c *Context) RequestBody() []byte
- func (c *Context) SaveToFile(fromFile, toFile string) error
- func (c *Context) ServerHTML(statusCode int, name string, data interface{})
- func (c *Context) ServerJSON(statusCode int, data interface{})
- func (c *Context) ServerString(statusCode int, msg string)
- func (c *Context) ServerXML(statusCode int, data interface{})
- func (c *Context) SetCookie(key, value string, maxAge int, path, domain string, secure, httpOnly bool)
- func (c *Context) SetHeader(key string, v string)
- func (c *Context) SetKey(key string, v interface{})
- func (c *Context) Status(statusCode int)
- func (c *Context) String(msg string)
- func (c *Context) URL() string
- func (c *Context) UserAgent() string
- func (c *Context) XML(data interface{})
- type Engine
- func (engine *Engine) AddFuncMap(key string, fn interface{})
- func (engine *Engine) Delims(left, right string)
- func (engine *Engine) NoMethod(handlers ...HandlerFunc)
- func (engine *Engine) NoRoute(handlers ...HandlerFunc)
- func (engine *Engine) RouterMap() (routes RoutesInfo)
- func (engine *Engine) Run(addr ...string) (err error)
- func (engine *Engine) RunTLS(certFile, keyFile string, addr ...string) (err error)
- func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (engine *Engine) SetAppConfig(app *AppConfig)
- func (engine *Engine) SetView(path ...string)
- type H
- type HandlerFunc
- type HandlersChain
- type Param
- type Params
- type ResponseWriter
- type RouteInfo
- type RouterGroup
- func (group *RouterGroup) Any(path string, handlers ...HandlerFunc)
- func (group *RouterGroup) DELETE(path string, handlers ...HandlerFunc)
- func (group *RouterGroup) GET(path string, handlers ...HandlerFunc)
- func (group *RouterGroup) Group(path string, handlers ...HandlerFunc) *RouterGroup
- func (group *RouterGroup) HEAD(path string, handlers ...HandlerFunc)
- func (group *RouterGroup) Handle(method, p string, handlers []HandlerFunc)
- func (group *RouterGroup) PATCH(path string, handlers ...HandlerFunc)
- func (group *RouterGroup) POST(path string, handlers ...HandlerFunc)
- func (group *RouterGroup) PUT(path string, handlers ...HandlerFunc)
- func (group *RouterGroup) Static(relativePath, root string)
- func (group *RouterGroup) StaticFS(relativePath string, fs http.FileSystem)
- func (group *RouterGroup) StaticFile(relativePath, filepath string)
- func (group *RouterGroup) TRACE(path string, handlers ...HandlerFunc)
- func (group *RouterGroup) Use(middleware ...HandlerFunc)
- type RouterMap
- type RoutesInfo
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BytesToString ¶
BytesToString converts byte slice to string without a memory allocation.
func DebugPrintError ¶
func DebugPrintError(err error)
func Dir ¶
func Dir(root string, listDirectory bool) http.FileSystem
Dir returns a http.Filesystem that can be used by http.FileServer(). It is used internally in router.Static(). if listDirectory == true, then it works the same as http.Dir() otherwise it returns a filesystem that prevents http.FileServer() to list the directory files.
func StringToBytes ¶
StringToBytes converts string to byte slice without a memory allocation.
Types ¶
type AppConfig ¶
type AppConfig struct { AppName string //名称 RunMode string //运行模式:dev|prod HttpAddr string //"127.0.0.1:8080" or ":8080" AutoRender bool //是否自动渲染html模板 Views string //html 模板目录 TemplateLeft string //html模板左符号 TemplateRight string //html模板右符号 }
AppConfig gow 配置入口 也可以通过此配置文件统一设置app的基础配置 除此之外,也可以通过
r := gow.Default() r.AutoRender = true r.AppName = "gow" r.SetView("view") 等方式设置
func GetAppConfig ¶
func GetAppConfig() *AppConfig
GetAppConfig 获取配置文件中的信息 默认使用conf/app.conf配置文件
当环境变量 APP_RUN_MODE ="prod"时,使用 conf/prod.app.conf 当环境变量 APP_RUN_MODE ="dev"时,使用 conf/dev.app.conf 没有此环境变量时,使用conf/app.conf
type Context ¶
type Context struct { Writer ResponseWriter Req *http.Request Keys map[string]interface{} Path string Method string IP string //方便外部其他方法设置IP Params Params StatusCode int // contains filtered or unexported fields }
Context gow context
func (*Context) DecodeJSONBody ¶
DecodeJSONBody
func (*Context) GetFiles ¶
func (c *Context) GetFiles(key string) ([]*multipart.FileHeader, error)
GetFiles get []file from form
func (*Context) GetFloat64 ¶
GetInt64 GetInt64
func (*Context) GetStrings ¶
GetStrings GetStrings
func (*Context) SaveToFile ¶
SaveToFile saves uploaded file to new path. on server
func (*Context) ServerHTML ¶
ServerHTML ServerHTML
func (*Context) ServerJSON ¶
ServerJSON response json format
func (*Context) ServerString ¶
WriteString response text
func (*Context) SetCookie ¶
func (c *Context) SetCookie(key, value string, maxAge int, path, domain string, secure, httpOnly bool)
SetCookie set cookie
c.SetCookie("url","22v.net",72*time.Hour,"",true,true)
type Engine ¶
type Engine struct { AppName string RunMode string AppPath string //程序的运行地址 *RouterGroup //template HTMLRender render.Render FuncMap template.FuncMap AutoRender bool //是否渲染模板 HandleMethodNotAllowed bool UseRawPath bool UnescapePathValues bool RemoveExtraSlash bool RedirectTrailingSlash bool RedirectFixedPath bool MaxMultipartMemory int64 // contains filtered or unexported fields }
func (*Engine) AddFuncMap ¶
AddFuncMap add fn func to template func map
func (*Engine) NoMethod ¶
func (engine *Engine) NoMethod(handlers ...HandlerFunc)
NoMethod sets the handlers called when... TODO.
func (*Engine) NoRoute ¶
func (engine *Engine) NoRoute(handlers ...HandlerFunc)
NoRoute adds handlers for NoRoute. It return a 404 code by default.
func (*Engine) RouterMap ¶
func (engine *Engine) RouterMap() (routes RoutesInfo)
RoutesMap get all router map
func (*Engine) ServeHTTP ¶
func (engine *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implement the http.handler interface
func (*Engine) SetAppConfig ¶
SetAppConfig 统一配置入口 可使用此方法统一配置,也可以使用其他方法单独设置
type HandlerFunc ¶
type HandlerFunc func(*Context)
HandlerFunc handler func
func Logger ¶
func Logger() HandlerFunc
gow 2020/07/01 - 14:55:52 | 200 | 44.961µs | 127.0.0.1 | GET "/article/1" Logger
print to console
func Recovery ¶
func Recovery() HandlerFunc
type HandlersChain ¶
type HandlersChain []HandlerFunc
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 ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter http.Hijacker http.Flusher http.CloseNotifier // Returns the HTTP response status code of the current request. Status() int // Returns the number of bytes already written into the response http body. // See Written() Size() int // Writes the string into the response body. WriteString(string) (int, error) // Returns true if the response body was already written. Written() bool // Forces to write the http header (status code + headers). WriteHeaderNow() // get the http.Pusher for server push Pusher() http.Pusher }
ResponseWriter ...
type RouteInfo ¶
type RouteInfo struct { Method string Path string Handler string HandlerFunc HandlerFunc }
RouteInfo represents a request route's specification which contains method and path and its handler.
type RouterGroup ¶
type RouterGroup struct { Handlers HandlersChain // contains filtered or unexported fields }
RouterGroup gow routerGroup
func (*RouterGroup) DELETE ¶
func (group *RouterGroup) DELETE(path string, handlers ...HandlerFunc)
DELETE
func (*RouterGroup) Group ¶
func (group *RouterGroup) Group(path string, handlers ...HandlerFunc) *RouterGroup
Group router group
func (*RouterGroup) HEAD ¶
func (group *RouterGroup) HEAD(path string, handlers ...HandlerFunc)
HEAD
func (*RouterGroup) Handle ¶
func (group *RouterGroup) Handle(method, p string, handlers []HandlerFunc)
Handle Handle
func (*RouterGroup) PATCH ¶
func (group *RouterGroup) PATCH(path string, handlers ...HandlerFunc)
PATCH
func (*RouterGroup) POST ¶
func (group *RouterGroup) POST(path string, handlers ...HandlerFunc)
POST
func (*RouterGroup) Static ¶
func (group *RouterGroup) Static(relativePath, root string)
Static 静态资源文件 use:
router.Static("/static","static")
func (*RouterGroup) StaticFS ¶
func (group *RouterGroup) StaticFS(relativePath string, fs http.FileSystem)
StaticFS
func (*RouterGroup) StaticFile ¶
func (group *RouterGroup) StaticFile(relativePath, filepath string)
StaticFile 实现了单个静态文件的路由 router.StaticFile("favicon.ico","./static/favicon.ico")
func (*RouterGroup) TRACE ¶
func (group *RouterGroup) TRACE(path string, handlers ...HandlerFunc)
TRACE
func (*RouterGroup) Use ¶
func (group *RouterGroup) Use(middleware ...HandlerFunc)
Use use middleware
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
lib
|
|
logy
like https://gitea.com/lunny/log but made some adjustments
|
like https://gitea.com/lunny/log but made some adjustments |
nsq
//init pu,err:=NewProducer("192.168.0.197",4150) if err!=nil{ //error } b,_:=json.Marshal(obj) //发送 err = pu.Publish("topic",b) if err!=nil{ //error }
|
//init pu,err:=NewProducer("192.168.0.197",4150) if err!=nil{ //error } b,_:=json.Marshal(obj) //发送 err = pu.Publish("topic",b) if err!=nil{ //error } |
oauth/wechat
微信第三方登录相关 公众号支付相关 全局token相关 client:=NewClient(appId,secret) client.SetApiKey("支付的apiKey") ....
|
微信第三方登录相关 公众号支付相关 全局token相关 client:=NewClient(appId,secret) client.SetApiKey("支付的apiKey") .... |
pay/wepay
基础通讯业务实现 sam
|
基础通讯业务实现 sam |
redis
使用方法: 1.
|
使用方法: 1. |
util
AES CBC PKCS5Padding加/解密 使用 hex.Encode 查看测试文件: aes_cbc_test.go http client 使用github.com/imroc/req库 返回string,如果需要到struct,需要自己反序列化
|
AES CBC PKCS5Padding加/解密 使用 hex.Encode 查看测试文件: aes_cbc_test.go http client 使用github.com/imroc/req库 返回string,如果需要到struct,需要自己反序列化 |
use https://github.com/gin-contrib/pprof/blob/master/pprof.go
|
use https://github.com/gin-contrib/pprof/blob/master/pprof.go |