Documentation ¶
Overview ¶
Package geneva is a simple web framework.
Index ¶
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithStatus(code int)
- func (c *Context) DefaultPostForm(key, defaultValue string) string
- func (c *Context) DefaultQuery(key, defaultValue string) string
- func (c *Context) Get(key string) (value any, exists bool)
- func (c *Context) GetPostForm(key string) (string, bool)
- func (c *Context) GetQuery(key string) (string, bool)
- func (c *Context) JSON(code int, obj any)
- func (c *Context) Next()
- func (c *Context) Param(key string) string
- func (c *Context) PostForm(key string) string
- func (c *Context) Query(key string) string
- func (c *Context) Set(key string, value any)
- func (c *Context) String(code int, msg string)
- type Engine
- type H
- type Handler
- type Handlers
- type RouterGroup
- func (rg *RouterGroup) DELETE(path string, handlers ...Handler)
- func (rg *RouterGroup) GET(path string, handlers ...Handler)
- func (rg *RouterGroup) Group(relativePath string, handlers ...Handler) *RouterGroup
- func (rg *RouterGroup) HEAD(path string, handlers ...Handler)
- func (rg *RouterGroup) Handle(method, relativePath string, handlers ...Handler)
- func (rg *RouterGroup) OPTIONS(path string, handlers ...Handler)
- func (rg *RouterGroup) PATCH(path string, handlers ...Handler)
- func (rg *RouterGroup) POST(path string, handlers ...Handler)
- func (rg *RouterGroup) PUT(path string, handlers ...Handler)
- func (rg *RouterGroup) Use(handlers ...Handler)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Writer http.ResponseWriter Request *http.Request Params httprouter.Params // contains filtered or unexported fields }
Context is argument of Handler.
func (*Context) Abort ¶
func (c *Context) Abort()
Abort prevents pending handlers from being called. Note that this will not stop the current handler.
func (*Context) AbortWithStatus ¶
AbortWithStatus calls `Abort()` and writes the headers with the specified status code.
func (*Context) DefaultPostForm ¶
DefaultPostForm returns the specified key from a POST urlencoded form or multipart form when it exists, otherwise it returns the specified defaultValue string. See: PostForm() and GetPostForm() for further information.
func (*Context) DefaultQuery ¶
DefaultQuery returns the keyed url query value if it exists, otherwise it returns the specified defaultValue string. See: Query() and GetQuery() for further information.
func (*Context) GetPostForm ¶
GetPostForm is like PostForm(key). It returns the specified key from a POST urlencoded form or multipart form when it exists `(value, true)` (even when the value is an empty string), otherwise it returns ("", false).
func (*Context) GetQuery ¶
GetQuery is like Query(), it returns the keyed url query value if it exists `(value, true)` (even when the value is an empty string), otherwise it returns `("", false)`.
func (*Context) Next ¶
func (c *Context) Next()
Next should be used only inside middleware. It executes the pending handlers in the chain inside the calling handler.
func (*Context) Param ¶
Param returns the value of the first Param which key matches the given name. If no matching Param is found, an empty string is returned.
func (*Context) PostForm ¶
PostForm returns the specified key from a POST urlencoded form or multipart form when it exists, otherwise it returns an empty string `("")`.
type Engine ¶
type Engine struct { *RouterGroup // contains filtered or unexported fields }
Engine is the framework's instance.
type Handler ¶
type Handler func(*Context)
Handler defines the handler used by geneva middleware as return value.
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
RouterGroup is used internally to configure router.
func (*RouterGroup) DELETE ¶
func (rg *RouterGroup) DELETE(path string, handlers ...Handler)
DELETE is a shortcut for geneva.Handler("DELETE", path, handlers)
func (*RouterGroup) GET ¶
func (rg *RouterGroup) GET(path string, handlers ...Handler)
GET is a shortcut for geneva.Handler("GET", path, handlers)
func (*RouterGroup) Group ¶
func (rg *RouterGroup) Group(relativePath string, handlers ...Handler) *RouterGroup
Group creates a new router group. You should add all the routes that have common middlewares or the same path prefix.
func (*RouterGroup) HEAD ¶
func (rg *RouterGroup) HEAD(path string, handlers ...Handler)
HEAD is a shortcut for geneva.Handler("HEAD", path, handlers)
func (*RouterGroup) Handle ¶
func (rg *RouterGroup) Handle(method, relativePath string, handlers ...Handler)
Handle registers a new request handle and middleware with the given path and method.
func (*RouterGroup) OPTIONS ¶
func (rg *RouterGroup) OPTIONS(path string, handlers ...Handler)
OPTIONS is a shortcut for geneva.Handler("OPTIONS", path, handlers)
func (*RouterGroup) PATCH ¶
func (rg *RouterGroup) PATCH(path string, handlers ...Handler)
PATCH is a shortcut for geneva.Handler("PATCH", path, handlers)
func (*RouterGroup) POST ¶
func (rg *RouterGroup) POST(path string, handlers ...Handler)
POST is a shortcut for geneva.Handler("POST", path, handlers)
func (*RouterGroup) PUT ¶
func (rg *RouterGroup) PUT(path string, handlers ...Handler)
PUT is a shortcut for geneva.Handler("PUT", path, handlers)
func (*RouterGroup) Use ¶
func (rg *RouterGroup) Use(handlers ...Handler)
Use adds middleware to the group.