Documentation ¶
Overview ¶
Codes from https://github.com/gin-gonic/gin/blob/master/debug.go
Index ¶
- Variables
- func EnsureTemplateName(s string, v ViewEngine) string
- func IsDebugging() bool
- type App
- func (app *App) ConfigurationReadOnly() *Configuration
- func (app *App) GetView() View
- func (app *App) RegisterView(viewEngine ViewEngine)
- func (app *App) Run(args ...string) (err error)
- func (app *App) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (app *App) View(writer io.Writer, filename string, bindingData interface{}) error
- type BlockEngine
- type Configuration
- type Context
- type Ctx
- func (c *Ctx) Data() M
- func (c *Ctx) Fail(code int, err string)
- func (c *Ctx) Get(key string) (value interface{}, exists bool)
- func (c *Ctx) GetView() View
- func (c *Ctx) HTML(name string, viewData ...interface{})
- func (c *Ctx) JSON(code int, obj interface{})
- func (c *Ctx) Next()
- func (c *Ctx) Param(key string) interface{}
- func (c *Ctx) Query(key string) string
- func (c *Ctx) QueryInt(key string) int
- func (c *Ctx) Request() *http.Request
- func (c *Ctx) Set(key string, value interface{})
- func (c *Ctx) SetData(data M)
- func (c *Ctx) SetHeader(key string, value string)
- func (c *Ctx) Status(code int)
- func (c *Ctx) StatusCode() int
- func (c *Ctx) String(code int, format string, values ...interface{})
- func (ctx *Ctx) ViewEngine(engine ViewEngine)
- func (ctx *Ctx) Write(rawBody []byte) (int, error)
- func (c *Ctx) Writer() http.ResponseWriter
- type Engine
- type Entry
- type H
- type Handler
- type HandlerFunc
- type HandlersChain
- type M
- type Map
- type MiddlewareFunc
- type PreMiddlewareFunc
- type Router
- type RouterGroup
- func (group *RouterGroup) Get(pattern string, handler HandlerFunc)
- func (group *RouterGroup) Group(prefix string) *RouterGroup
- func (group *RouterGroup) NoMethod(handler HandlerFunc)
- func (group *RouterGroup) NoRoute(handler HandlerFunc)
- func (group *RouterGroup) Post(pattern string, handler HandlerFunc)
- func (group *RouterGroup) RegisterView(viewEngine ViewEngine)
- func (group *RouterGroup) SetRender(render ViewEngine)
- func (group *RouterGroup) Static(relativePath string, root string)
- func (group *RouterGroup) Use(middlewares ...HandlerFunc)
- type Store
- func (r *Store) Get(key string) interface{}
- func (r *Store) GetDefault(key string, def interface{}) interface{}
- func (r *Store) GetEntry(key string) (Entry, bool)
- func (r *Store) Save(key string, value interface{}, immutable bool) (Entry, bool)
- func (r *Store) Set(key string, value interface{}) (Entry, bool)
- type ValueSetter
- type View
- type ViewEngine
Constants ¶
This section is empty.
Variables ¶
var DebugPrintRouteFunc func(httpMethod, absolutePath, handlerName string, nuHandlers int)
DebugPrintRouteFunc indicates debug log output format.
var DefaultWriter io.Writer = os.Stdout
Functions ¶
func EnsureTemplateName ¶ added in v0.2.0
func EnsureTemplateName(s string, v ViewEngine) string
Get filename by viewEngine
func IsDebugging ¶
func IsDebugging() bool
Types ¶
type App ¶
type App struct { *RouterGroup // contains filtered or unexported fields }
func (*App) ConfigurationReadOnly ¶ added in v0.2.0
func (app *App) ConfigurationReadOnly() *Configuration
ConfigurationReadOnly returns an object which doesn't allow field writing.
func (*App) RegisterView ¶ added in v0.2.0
func (app *App) RegisterView(viewEngine ViewEngine)
type BlockEngine ¶ added in v0.2.0
type BlockEngine struct{}
type Configuration ¶ added in v0.2.0
type Configuration struct { // Defaults to "rock.view.engine". ViewEngineContextKey string `ini:"view_engine_context_key" json:"viewEngineContextKey,omitempty" yaml:"ViewEngineContextKey" toml:"ViewEngineContextKey"` // ViewLayoutContextKey is the context's values key // responsible to store and retrieve(string) the current view layout. // A middleware can modify its associated value to change // the layout that `ctx.View` will use to render a template. // // Defaults to "rock.view.layout". ViewLayoutContextKey string `ini:"view_layout_context_key" json:"viewLayoutContextKey,omitempty" yaml:"ViewLayoutContextKey" toml:"ViewLayoutContextKey"` // ViewDataContextKey is the context's values key // responsible to store and retrieve(interface{}) the current view binding data. // A middleware can modify its associated value to change // the template's data on-fly. // // Defaults to "rock.view.data". ViewDataContextKey string `ini:"view_data_context_key" json:"viewDataContextKey,omitempty" yaml:"ViewDataContextKey" toml:"ViewDataContextKey"` // FallbackViewContextKey is the context's values key // responsible to store the view fallback information. // // Defaults to "rock.view.fallback". FallbackViewContextKey string `` /* 131-byte string literal not displayed */ }
func DefaultConfiguration ¶ added in v0.2.0
func DefaultConfiguration() Configuration
func (*Configuration) GetViewDataContextKey ¶ added in v0.2.0
func (c *Configuration) GetViewDataContextKey() string
GetViewDataContextKey returns the ViewDataContextKey field.
func (*Configuration) GetViewEngineContextKey ¶ added in v0.2.0
func (c *Configuration) GetViewEngineContextKey() string
GetViewDataContextKey returns the ViewDataContextKey field.
type Context ¶
type Context interface { Request() *http.Request Writer() http.ResponseWriter Next() // writer Write(rawBody []byte) (int, error) // response method StatusCode() int Status(code int) SetHeader(key string, value string) Fail(code int, err string) String(code int, format string, values ...interface{}) JSON(code int, obj interface{}) // request method Param(key string) interface{} Query(key string) string QueryInt(key string) int // render // HTML(code int, name string, data interface{}) ViewEngine(engine ViewEngine) HTML(name string, viewData ...interface{}) Data() M SetData(M) Set(key string, value interface{}) Get(key string) (value interface{}, exists bool) GetView() View }
type Ctx ¶
type Ctx struct { // request info Path string Method string // contains filtered or unexported fields }
func (*Ctx) StatusCode ¶ added in v0.2.0
func (*Ctx) ViewEngine ¶ added in v0.2.0
func (ctx *Ctx) ViewEngine(engine ViewEngine)
func (*Ctx) Write ¶ added in v0.2.0
Write writes the data to the connection as part of an HTTP reply.
If WriteHeader has not yet been called, Write calls WriteHeader(http.StatusOK) before writing the data. If the Header does not contain a Content-Type line, Write adds a Content-Type set to the result of passing the initial 512 bytes of written data to DetectContentType.
Depending on the HTTP protocol version and the client, calling Write or WriteHeader may prevent future reads on the Request.Body. For HTTP/1.x requests, handlers should read any needed request body data before writing the response. Once the headers have been flushed (due to either an explicit Flusher.Flush call or writing enough data to trigger a flush), the request body may be unavailable. For HTTP/2 requests, the Go HTTP server permits handlers to continue to read the request body while concurrently writing the response. However, such behavior may not be supported by all HTTP/2 clients. Handlers should read before writing if possible to maximize compatibility.
func (*Ctx) Writer ¶ added in v0.2.0
func (c *Ctx) Writer() http.ResponseWriter
type Engine ¶ added in v0.2.0
type Engine = ViewEngine
type Entry ¶ added in v0.2.0
type Entry struct { Key string `json:"key" msgpack:"key" yaml:"Key" toml:"Value"` ValueRaw interface{} `json:"value" msgpack:"value" yaml:"Value" toml:"Value"` // contains filtered or unexported fields }
type Handler ¶
type Handler = HandlerFunc
type HandlerFunc ¶
type HandlerFunc func(Context)
func Recovery ¶ added in v0.2.0
func Recovery() HandlerFunc
type HandlersChain ¶
type HandlersChain []HandlerFunc
func (HandlersChain) Last ¶ added in v0.2.0
func (c HandlersChain) Last() HandlerFunc
Last returns the last handler in the chain. ie. the last handler is the main one.
type MiddlewareFunc ¶ added in v0.2.0
type MiddlewareFunc = HandlerFunc
type PreMiddlewareFunc ¶ added in v0.2.0
type PreMiddlewareFunc = HandlerFunc
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Mux is a tire base HTTP request router which can be used to dispatch requests to different handler functions.
func (*Router) Get ¶ added in v0.2.0
func (r *Router) Get(pattern string, handler HandlerFunc)
Get registers a new GET route for a path with matching handler in the Router.
func (*Router) Handle ¶
func (r *Router) Handle(method, pattern string, handler HandlerFunc)
type RouterGroup ¶ added in v0.2.0
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) Get ¶ added in v0.2.0
func (group *RouterGroup) Get(pattern string, handler HandlerFunc)
func (*RouterGroup) Group ¶ added in v0.2.0
func (group *RouterGroup) Group(prefix string) *RouterGroup
func (*RouterGroup) NoMethod ¶ added in v0.2.0
func (group *RouterGroup) NoMethod(handler HandlerFunc)
func (*RouterGroup) NoRoute ¶ added in v0.2.0
func (group *RouterGroup) NoRoute(handler HandlerFunc)
func (*RouterGroup) Post ¶ added in v0.2.0
func (group *RouterGroup) Post(pattern string, handler HandlerFunc)
func (*RouterGroup) RegisterView ¶ added in v0.2.0
func (group *RouterGroup) RegisterView(viewEngine ViewEngine)
func (*RouterGroup) SetRender ¶ added in v0.2.0
func (group *RouterGroup) SetRender(render ViewEngine)
func (*RouterGroup) Static ¶ added in v0.2.0
func (group *RouterGroup) Static(relativePath string, root string)
serve static files
func (*RouterGroup) Use ¶ added in v0.2.0
func (group *RouterGroup) Use(middlewares ...HandlerFunc)
type Store ¶ added in v0.2.0
type Store []Entry
func (*Store) Get ¶ added in v0.2.0
Get returns the entry's value based on its key. If not found returns nil.
func (*Store) GetDefault ¶ added in v0.2.0
GetDefault returns the entry's value based on its key. If not found returns "def". This function checks for immutability as well, the rest don't.
func (*Store) GetEntry ¶ added in v0.2.0
GetEntry returns a pointer to the "Entry" found with the given "key" if nothing found then it returns an empty Entry and false.
type ValueSetter ¶ added in v0.2.0
type View ¶ added in v0.2.0
type View struct {
Engine ViewEngine
}
func (*View) ExecuteWriter ¶ added in v0.2.0
ExecuteWriter calls the correct view Engine's ExecuteWriter func
func (*View) Registered ¶ added in v0.2.0
Registered reports whether an engine was registered.