Documentation
¶
Index ¶
- Constants
- type Application
- type BaseCommand
- type Binding
- type BindingFile
- type Cache
- type CacheSerializable
- type CacheStore
- type Command
- type Configuration
- type Container
- type Context
- type ContextEntity
- type ContextHandler
- type ContextPool
- type Cron
- type CronJob
- type Error
- type ErrorRender
- type ErrorStack
- type Event
- type EventHandler
- type FileInfo
- type GORMQueryMagic
- type HttpProtocol
- type HttpRoute
- type HttpRouteGroup
- type HttpRouter
- type HttpWrapResponseWriter
- type Jwt
- type JwtAudience
- type JwtStore
- type Loggable
- type Notify
- type NotifyInfo
- type Pool
- type PoolFunc
- type Protocol
- type Provider
- type Render
- type ResourceCollectionData
- type ResourceData
- type ResourceDataCollection
- type ResourceDatable
- type ResourceFields
- type ResourceLink
- type ResourceLinkData
- type ResourceMeta
- type ResourceMetaData
- type ResourceResolveData
- type ResourceResolver
- type ResourceTransformer
- type Scheduler
- type SchedulerFailed
- type SchedulerHandler
- type SchedulerMessage
- type Server
- type Session
- type Storage
- type StorageInfo
- type StorageMetadata
- type Token
- type UploadOption
- type Validator
Constants ¶
View Source
const ( ModeDevelopment uint8 = iota ModeProduction ModeTesting )
View Source
const ( HttpMimeJson = "application/json" HttpMimeHtml = "text/html" HttpMimeXml = "application/xml" HttpMimePlain = "text/plain" HttpMimeForm = "application/x-www-form-urlencoded" HttpMimeMultipartForm = "multipart/form-data" HttpMimeStream = "application/octet-stream" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application interface { Container Pool SetMode(mode uint8) Version() string Mode() uint8 IsDevelopment() bool IsProduction() bool IsTesting() bool Resolve(abstract interface{}, params ...interface{}) interface{} Boot() Register(provider Provider, force bool) RegisterMultiple(providers []Provider, force bool) HasProvider(name string) bool GetProvider(name string) Provider Reset() }
type BaseCommand ¶
type BindingFile ¶
type BindingFile interface { Files(key string) []*multipart.FileHeader File(key string) *multipart.FileHeader Save(key string, option *UploadOption) ([]*FileInfo, error) SaveAll(option *UploadOption) (map[string][]*FileInfo, error) }
type Cache ¶
type Cache interface { Driver(driver string) CacheSerializable Register(driver string, store CacheStore) CacheStore CacheSerializable }
type CacheSerializable ¶
type CacheSerializable interface { Store() CacheStore GetDefault(key string, defaultValue interface{}) (interface{}, error) Pull(key string) (interface{}, error) PullDefault(key string, defaultValue interface{}) (interface{}, error) GetDecode(key string, to interface{}) (interface{}, error) AddEncode(key string, value interface{}, expire time.Time) error ForeverEncode(key string, value interface{}) error PutEncode(key string, value interface{}, expire time.Time) error }
type CacheStore ¶
type CacheStore interface { Get(key string) (interface{}, error) Add(key string, value interface{}, expire time.Time) error Put(key string, value interface{}, expire time.Time) error Forever(key string, value interface{}) error Forget(key string) error Increment(key string, steps ...int64) error Decrement(key string, steps ...int64) error Has(key string) bool Flush() error }
type Configuration ¶
type Configuration interface { Bind(key string, val interface{}) error Get(key string) interface{} GetBool(key string) bool GetFloat(key string) float64 GetInt(key string) int GetIntSlice(key string) []int GetString(key string) string GetStringMap(key string) map[string]interface{} GetStringMapString(key string) map[string]string GetStringSlice(key string) []string GetTime(key string) time.Time GetDuration(key string) time.Duration Exists(key string) bool Set(key string, value interface{}) SetDefault(key string, value interface{}) Clone() Configuration }
type Context ¶
type Context interface { context.Context Application() Application Protocol() Protocol Next() Handlers() []ContextHandler AddEntity(key string, value interface{}) Entity(key string) *ContextEntity Abort() Current() int Error(status int, err ...interface{}) Bind(v interface{}) error BindValidate(v interface{}) error BindWith(b Binding, v interface{}) error BindWithValidate(b Binding, v interface{}) error Get(key string) interface{} Render(status int, v interface{}) error RenderWith(status int, r Render, v interface{}) error Clone() Context // application make method Resolve(abstract interface{}, params ...interface{}) interface{} }
type ContextEntity ¶
type ContextEntity struct { Key string Value interface{} }
type ContextHandler ¶
type ContextHandler func(c Context)
type ContextPool ¶
type ContextPool interface { New(application Application) Context Get() Context Release(Context) }
type Cron ¶
type Cron interface { Start() Stop() // Perform tasks at a custom time RunWithFunc(spec string, job func()) RunWithJob(spec string, job CronJob) // Execute task in specified seconds SecondsWithFunc(seconds int, job func()) SecondsWithJob(seconds int, job CronJob) // Perform a task every second EverySecondWithFunc(job func()) EverySecondWithJob(job CronJob) // Execute task in specified minutes MinutesWithFunc(minutes int, job func()) MinutesWithJob(minutes int, job CronJob) // Perform a task every minute EveryMinuteWithFunc(job func()) EveryMinuteWithJob(job CronJob) // Execute task in specified hours HoursWithFunc(hours int, job func()) HoursWithJob(hours int, job CronJob) // Perform a task every hour EveryHourWithFunc(job func()) EveryHourWithJob(job CronJob) // Run at a specified time every day DayAtWithFunc(hour int, job func()) DayAtWithJob(hour int, job CronJob) // Every day at 0 o'clock EveryDayWithFunc(job func()) EveryDayWithJob(job CronJob) // Perform the task at 0:00 every Sunday EveryWeeklyWithFunc(job func()) EveryWeeklyWithJob(job CronJob) // Perform a task at N points of N every week WeeklyOnWithFunc(week, hour int, job func()) WeeklyOnWithJob(week, hour int, job CronJob) }
type ErrorRender ¶
type ErrorStack ¶
type Event ¶
type Event interface { Listen(name string, handlers ...EventHandler) Dispatch(name string, params ...interface{}) []interface{} Has(name string) bool }
type EventHandler ¶
type EventHandler interface {
Handle(application Application, params ...interface{}) (interface{}, error)
}
type HttpProtocol ¶
type HttpProtocol interface { Protocol Request() *http.Request ResponseWriter() HttpWrapResponseWriter SetHeader(key, value string) SetParams(params []httprouter.Param) Params() []httprouter.Param Param(key string) httprouter.Param SetRoute(route HttpRoute) Route() HttpRoute Header(key string) string SetSession(session Session) Session() Session SessionValue(key string) interface{} IsContentType(key string) bool IsAccept(key string) bool IsMethod(key string) bool ContentType() string Accept() []string SetStatus(status int) SetCookie(cookie *http.Cookie) Cookie(name string) (string, error) Redirect(status int, location string) ClientIP() string }
type HttpRoute ¶
type HttpRoute interface { Name(name string) HttpRoute Use(handlers ...ContextHandler) HttpRoute Handlers() []ContextHandler }
type HttpRouteGroup ¶
type HttpRouteGroup interface { Prefix(prefix string) HttpRouteGroup Use(handlers ...ContextHandler) HttpRouteGroup GET(path string, handler ContextHandler) HttpRoute POST(path string, handler ContextHandler) HttpRoute PUT(path string, handler ContextHandler) HttpRoute PATCH(path string, handler ContextHandler) HttpRoute DELETE(path string, handler ContextHandler) HttpRoute OPTIONS(path string, handler ContextHandler) HttpRoute Group(prefix string) HttpRouteGroup Handler(method, path string, handler http.HandlerFunc) }
type HttpRouter ¶
type HttpRouter interface { GET(path string, handler ContextHandler) HttpRoute POST(path string, handler ContextHandler) HttpRoute PUT(path string, handler ContextHandler) HttpRoute PATCH(path string, handler ContextHandler) HttpRoute DELETE(path string, handler ContextHandler) HttpRoute OPTIONS(path string, handler ContextHandler) HttpRoute // serve static files Static(path string, root string) HttpRouter Handler(method, path string, handler http.HandlerFunc) HttpRouter() *httprouter.Router Group(prefix string) HttpRouteGroup ServeHTTP(w http.ResponseWriter, req *http.Request) }
type HttpWrapResponseWriter ¶
type HttpWrapResponseWriter interface { http.ResponseWriter StatusCode() int }
type JwtAudience ¶
type JwtAudience interface {
Audience() string
}
type JwtStore ¶
type JwtStore interface { Has(id string) bool Put(id string, audience JwtAudience, lifetime time.Time) error Forget(audience JwtAudience) error }
type Notify ¶
type Notify func(blockCount int, info *NotifyInfo, err error)
type NotifyInfo ¶
type PoolFunc ¶
type PoolFunc func(application Application) interface{}
type Protocol ¶
type Protocol interface { io.Reader io.Writer Application() Application Name() string // Protocol metadata Metadata() map[string][]string // Full protocol message Message() ([]byte, error) Values() map[string][]string Clone() Protocol }
整个协议的生命周期 包括,协议名称,本身详情,数据完整的数据报,普通value,文件生成,以及协议返回的输出
type ResourceCollectionData ¶
type ResourceCollectionData interface {
CollectionData() ResourceDataCollection
}
type ResourceData ¶
type ResourceData map[string]interface{}
type ResourceDataCollection ¶
type ResourceDataCollection []ResourceData
type ResourceDatable ¶
type ResourceDatable interface {
Data() ResourceData
}
type ResourceFields ¶
type ResourceFields []string
type ResourceLink ¶
type ResourceLink interface { SetLink(links ResourceLinkData) Link() ResourceLinkData }
type ResourceLinkData ¶
type ResourceMeta ¶
type ResourceMeta interface { SetMeta(meta ResourceMetaData) Meta() ResourceMetaData }
type ResourceMetaData ¶
type ResourceMetaData map[string]interface{}
type ResourceResolveData ¶
type ResourceResolveData map[string]interface{}
type ResourceResolver ¶
type ResourceResolver interface {
Resolve() interface{}
}
type ResourceTransformer ¶
type ResourceTransformer interface { Resource() interface{} SetResource(resource interface{}) }
type Scheduler ¶
type Scheduler interface { Send(message *SchedulerMessage) error Run() error Close() error Decrement(workerNum int32) Increment(workerNum int32) error RegisterHandler(name string, handler SchedulerHandler) }
type SchedulerFailed ¶
type SchedulerFailed interface {
Failed(err error)
}
type SchedulerHandler ¶
type SchedulerHandler interface {
Handle(message *SchedulerMessage) error
}
type SchedulerMessage ¶
type Storage ¶
type Storage interface { Url(key string, params url.Values) string FormUpload(ctx context.Context, metadata *StorageMetadata) (*StorageInfo, error) PartUpload(ctx context.Context, metadata *StorageMetadata, notify Notify) (*StorageInfo, error) Token() string Callback(req *http.Request) (*StorageInfo, error) }
type StorageInfo ¶
type StorageMetadata ¶
type StorageMetadata struct { Path string Name string Mime string Data []byte Size int64 File io.Reader }
得到的上传元数据
func (*StorageMetadata) GenerateNewName ¶
func (a *StorageMetadata) GenerateNewName() string
type UploadOption ¶
Click to show internal directories.
Click to hide internal directories.