Documentation
¶
Index ¶
- Constants
- func ALL(path string, handler Handler)
- func DELETE(path string, handler Handler)
- func GET(path string, handler Handler)
- func HEAD(path string, handler Handler)
- func PATCH(path string, handler Handler)
- func POST(path string, handler Handler)
- func PUT(path string, handler Handler)
- func Run() error
- func SetCorsConfig(corsConfig *CorsConfig)
- func SetCurlConfig(curlConfig *CurlConfig)
- func SetJwtConfig(jwtConfig *JwtConfig)
- func SetLoggerConfig(loggerConfig *LoggerConfig)
- func SetNotFoundHandle(nfh NotFoundHandle)
- func SetOrmConfig(ormConfig *OrmConfig)
- func SetPanicHandler(ph PanicHandler)
- func SetRedisConfig(redisConfig *RedisConfig)
- func SetServerConfig(serverConfig *ServerConfig)
- func Use(m Middleware)
- type Application
- type Claims
- type Conditions
- type Context
- func (c *Context) Body(body string)
- func (c *Context) Download(filePath string)
- func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
- func (c *Context) GetApp() *Application
- func (c *Context) GetBoolParam(key string) (value bool)
- func (c *Context) GetBoolParamDefault(key string, def bool) (value bool)
- func (c *Context) GetData(key string) (value interface{}, exists bool)
- func (c *Context) GetFloat64Param(key string) (value float64)
- func (c *Context) GetFloat64ParamDefault(key string, def float64) (value float64)
- func (c *Context) GetHeader(key string) string
- func (c *Context) GetHeaders() map[string][]string
- func (c *Context) GetHost() string
- func (c *Context) GetHostname() string
- func (c *Context) GetHref() string
- func (c *Context) GetInt64Param(key string) (value int64)
- func (c *Context) GetInt64ParamDefault(key string, def int64) (value int64)
- func (c *Context) GetIntParam(key string) (value int)
- func (c *Context) GetIntParamDefault(key string, def int) (value int)
- func (c *Context) GetLength() int
- func (c *Context) GetMethod() string
- func (c *Context) GetOrigin() string
- func (c *Context) GetProtocol() string
- func (c *Context) GetQuery() url.Values
- func (c *Context) GetQuerystring() string
- func (c *Context) GetStatusCode() int
- func (c *Context) GetStringParam(key string) (value string)
- func (c *Context) GetStringParamDefault(key string, def string) (value string)
- func (c *Context) GetUri() string
- func (c *Context) GetUserAgent() string
- func (c *Context) IsSecure() bool
- func (c *Context) Json(data map[string]interface{})
- func (c *Context) Parse(object interface{}) error
- func (c *Context) Redirect(url string, code int)
- func (c *Context) Render(tmpFile string, data map[string]interface{})
- func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string, flag int) error
- func (c *Context) SetData(key string, value interface{})
- func (c *Context) SetHeader(key, value string) *Context
- func (c *Context) SetLength(length int) *Context
- func (c *Context) SetStatus(code int) *Context
- type CorsConfig
- type Curl
- type CurlConfig
- type CurlResult
- type FieldValidateError
- type Fields
- type Handler
- type Jwt
- type JwtConfig
- type LoggerConfig
- type Middleware
- type Next
- type NotExistError
- type NotFoundHandle
- type Orm
- type OrmColumn
- type OrmConfig
- type OrmFromTable
- type OrmGroupBy
- type OrmJoin
- type OrmJoinType
- type OrmLimit
- type OrmOp
- type OrmOrderBy
- type OrmPool
- type OrmWhere
- type PanicHandler
- type RedisClient
- type RedisConfig
- type RedisResult
- type ServerConfig
Constants ¶
View Source
const ( HttpMethodGet = "GET" HttpMethodHead = "HEAD" HttpMethodOptions = "OPTIONS" HttpMethodPost = "POST" HttpMethodPut = "PUT" HttpMethodPatch = "PATCH" HttpMethodDelete = "DELETE" )
定义请求的方法
View Source
const ( HttpHeaderContentType = "Content-Type" HttpHeaderContentLength = "Content-Length" HttpHeaderTransferEncoding = "Transfer-Encoding" HttpHeaderContentDisposition = "Content-Disposition" HttpHeaderContentTransferEncoding = "Content-Transfer-Encoding" HttpHeaderExpires = "Expires" HttpHeaderCacheControl = "Cache-Control" HttpHeaderEtag = "Etag" HttpHeaderXForwardedHost = "X-Forwarded-Host" HttpHeaderXForwardedProto = "X-Forwarded-Proto" HttpHeaderIfModifiedSince = "If-Modified-Since" HttpHeaderIfNoneMatch = "If-None-Match" HttpHeaderLastModified = "Last-Modified" HttpHeaderXContentTypeOptions = "X-Content-Type-Options" HttpHeaderXPoweredBy = "X-Powered-By" HttpHeaderCorsOrigin = "Access-Control-Allow-Origin" HttpHeaderCorsMethods = "Access-Control-Allow-Methods" HttpHeaderCorsHeaders = "Access-Control-Allow-Headers" HttpHeaderCorsMaxAge = "Access-Control-Max-Age" )
定义http头
View Source
const Nil = NotExistError("flow-redis: key not exist")
Variables ¶
This section is empty.
Functions ¶
func SetNotFoundHandle ¶ added in v1.0.3
func SetNotFoundHandle(nfh NotFoundHandle)
func SetPanicHandler ¶ added in v1.0.3
func SetPanicHandler(ph PanicHandler)
Types ¶
type Claims ¶ added in v1.4.4
type Claims struct {
jwt.StandardClaims
Data map[string]interface{}
}
type Conditions ¶ added in v1.4.9
type Conditions struct {
// contains filtered or unexported fields
}
func (*Conditions) Add ¶ added in v1.4.9
func (c *Conditions) Add(columnName, op string, val interface{}, table ...string) *Conditions
添加查询条件,可以链式处理
func (*Conditions) Get ¶ added in v1.4.9
func (c *Conditions) Get() []*OrmWhere
type Context ¶
type Context struct {
Logger *log.Logger // 上下文的logger对象,打印日志会自动带上请求的相关参数
Orm *Orm // 数据库操作对象,引用app的orm对象
Redis *RedisClient // redis操作对象,引用app的redis对象
Curl *Curl // httpclient操作对象,引用app的curl对象
Jwt *Jwt // JWT操作对象,引用app的jwt对象
// contains filtered or unexported fields
}
定义请求上下文对象
func (*Context) FormFile ¶ added in v1.4.9
func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
func (*Context) GetBoolParam ¶ added in v1.4.9
获取请求的bool参数,如果参数类型不是bool,则会转换成bool,只支持基本类型转换
func (*Context) GetBoolParamDefault ¶ added in v1.4.9
GetBoolParam方法的带默认值
func (*Context) GetFloat64Param ¶ added in v1.4.9
获取请求的float64参数,如果参数类型不是float64,则会转换成float64,只支持基本类型转换
func (*Context) GetFloat64ParamDefault ¶ added in v1.4.9
GetFloat64Param方法的带默认值
func (*Context) GetInt64Param ¶ added in v1.4.9
获取请求的int64参数,如果参数类型不是int64,则会转换成int64,只支持基本类型转换
func (*Context) GetInt64ParamDefault ¶ added in v1.4.9
GetInt64Param方法的带默认值
func (*Context) GetIntParam ¶ added in v1.4.9
获取请求的int参数,如果参数类型不是int,则会转换成int,只支持基本类型转换
func (*Context) GetIntParamDefault ¶ added in v1.4.9
GetIntParam方法的带默认值
func (*Context) GetStringParam ¶ added in v1.4.9
获取请求的string参数,如果参数类型不是string,则会转换成string,只支持基本类型转换
func (*Context) GetStringParamDefault ¶ added in v1.4.9
GetStringParam方法的带默认值
func (*Context) SaveUploadedFile ¶ added in v1.4.9
保存上传的文件到指定位置
type CorsConfig ¶ added in v1.3.3
type CorsConfig struct {
Enable bool // 是否开启跨域支持
AllowOrigin string
AllowedHeaders string
AllowedMethods string
}
定义跨域配置
type Curl ¶ added in v1.3.3
type Curl struct {
// contains filtered or unexported fields
}
定义httpclient对象
type CurlConfig ¶ added in v1.3.3
type CurlConfig struct {
Timeout time.Duration // 请求的超时时间,单位秒
Headers map[string]string // 统一请求的头信息
}
定义httpclient配置
type CurlResult ¶ added in v1.3.3
type CurlResult []byte
定义返回的结果
func (CurlResult) Parse ¶ added in v1.3.3
func (cr CurlResult) Parse(v interface{}) error
将返回的结果定义到给定的对象里
type FieldValidateError ¶ added in v1.4.9
func (*FieldValidateError) Error ¶ added in v1.4.9
func (e *FieldValidateError) Error() string
type Fields ¶ added in v1.4.9
type Fields struct {
// contains filtered or unexported fields
}
定义查询字符段的结构体
type LoggerConfig ¶ added in v1.2.0
定义日志配置
type NotExistError ¶ added in v1.3.3
type NotExistError string
定义redis键不存在错误对象
func (NotExistError) Error ¶ added in v1.3.3
func (e NotExistError) Error() string
func (NotExistError) NotExistError ¶ added in v1.3.3
func (NotExistError) NotExistError()
type NotFoundHandle ¶ added in v1.0.2
type NotFoundHandle func(w http.ResponseWriter, r *http.Request)
func (NotFoundHandle) ServeHTTP ¶ added in v1.0.2
func (f NotFoundHandle) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Orm ¶ added in v1.2.0
type Orm struct {
Op *OrmOp // 数据库查询条件操作符对象
JoinType *OrmJoinType // 数据库JOIN表类型对象
// contains filtered or unexported fields
}
定义数据库操作对象
func (*Orm) Count ¶ added in v1.2.6
func (orm *Orm) Count(count *int64, fromTable *OrmFromTable, conditions []*OrmWhere) error
返回查询的总条数
func (*Orm) NewConditions ¶ added in v1.4.9
func (orm *Orm) NewConditions() *Conditions
func (*Orm) Query ¶ added in v1.2.6
func (orm *Orm) Query(dest interface{}, fields interface{}, fromTable *OrmFromTable, conditions []*OrmWhere, orderBy []*OrmOrderBy, limit *OrmLimit, groupBy *OrmGroupBy) error
数据库查询方法
type OrmConfig ¶ added in v1.2.0
type OrmConfig struct {
Enable bool
UserName string
Password string
DbName string
Host string
Port int
Pool *OrmPool
}
定义数据库配置
type OrmFromTable ¶ added in v1.2.6
定义数据库查询表结构
type OrmGroupBy ¶ added in v1.2.6
定义数据库GROUP BY结构
type OrmJoin ¶ added in v1.2.6
type OrmJoin struct {
Type string // JOIN类型
Table string // 表名
Alias string // 别名
ON []*OrmWhere // JOIN条件
}
定义数据库JOIN表结构
type OrmJoinType ¶ added in v1.2.7
定义数据库JOIN表类型
type OrmOp ¶ added in v1.2.6
type OrmOp struct {
Eq string
Gt string
Gte string
Lt string
Lte string
IN string
Like string
Or string
}
定义数据库查询条件操作符
type OrmOrderBy ¶ added in v1.2.6
定义数据库ORDER BY结构
type PanicHandler ¶ added in v1.0.2
type PanicHandler func(http.ResponseWriter, *http.Request, interface{})
type RedisClient ¶ added in v1.3.3
type RedisClient struct {
NotExist NotExistError
// contains filtered or unexported fields
}
定义redis操作对象
func (*RedisClient) Close ¶ added in v1.4.9
func (rd *RedisClient) Close() error
func (*RedisClient) Delete ¶ added in v1.4.9
func (rd *RedisClient) Delete(key string) error
func (*RedisClient) Get ¶ added in v1.3.3
func (rd *RedisClient) Get(key string) (RedisResult, error)
type RedisConfig ¶ added in v1.3.3
type RedisConfig struct {
Enable bool
Password string
DbNum int
Host string
Port int
Prefix string
}
定义redis配置结构
type RedisResult ¶ added in v1.4.9
type RedisResult string
定义返回的结果
func (RedisResult) Parse ¶ added in v1.4.9
func (rr RedisResult) Parse(v interface{}) error
将返回的结果定义到给定的对象里
Source Files
¶
Click to show internal directories.
Click to hide internal directories.