Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HandlerFunc ¶
type HandlerFunc func(c IContext)
type ICache ¶
type ICache interface { // Set the cache can use max bytes. SetMaxBytes(maxBytes int64) // Get value by key.If the key is expired, return "nil,false". Get(key string) (value interface{}, ok bool) // Add cache key. Add(key string, value interface{}) // Add cache key with expire time. AddWithExpire(key string, value interface{}, expireDuration time.Duration) // Delete cache key. Delete(key string) }
Memory cache.
type IContext ¶
type IContext interface { // Clone an IContext Clone() IContext // Injecting dependencies and reset this Context. In order to use sync.Pool to reuse Context. Reset(http.ResponseWriter, *http.Request, IMiddleware) // Get http request info. Request() IRequest // Get http response info. Response() IResponse // Get middleware in context. Middleware() IMiddleware // Next middleware. Next() }
IContext Save http request data.
type IInjector ¶
type IInjector interface { // Add singleton objects to the container. AddSingleton(objects ...interface{}) // Add Transient objects to the container, create a new object in every reuqest. AddTransient(objects ...interface{}) // Inject object in the request is coming. Inject(value reflect.Value) }
The DI container, regist object in the linweb init.
type IMiddleware ¶
type IMiddleware interface { //Clone an IMiddleware Clone() IMiddleware // Add middlewares to the request context. AddMiddlewares(middlewareFunc ...HandlerFunc) // Call the next middleware. Next(c IContext) }
type IModel ¶
type IModel interface { // New create a new model New(model interface{}) IModel // Validate follow the rules to validate this model. Validate() IModel // MapToByFieldName map this model to target model by field name. MapToByFieldName(dest interface{}) IModel // MapToByFieldTag map this model to target model by field tag. MapToByFieldTag(dest interface{}) IModel // MapFromByFieldName this model is map from source model by field name. MapFromByFieldName(src interface{}) IModel // MapFromByFieldTag this model is map from source model by field tag. MapFromByFieldTag(src interface{}) IModel // model chain error ModelError() error }
IModel is used to represent a struct that needs to be processed, it uses chain call, can call continuously and finally output ModelError.
type IRequest ¶
type IRequest interface { // PostForm get post form PostForm(key string) string // Query get query data in url Query(key string) string // Get url path. Path() string // Get http method. Method() string // Get request body. Body() string // SetParams set params in url SetParams(map[string]string) // Param get param in url Param(string) string }
IRequest Get request data in *http.Request
type IResponse ¶
type IResponse interface { // Status set response status Status(code int) // Header set response header Header(key string, value string) // Data set response body data Data(code int, data []byte) // String set response body data with string String(code int, format string, values ...interface{}) // JSON set response body data with json JSON(code int, obj interface{}) // HTML set response body data with html HTML(code int, html string) }
IResponse Set response data to http.ResponseWriter
Click to show internal directories.
Click to hide internal directories.