Documentation
¶
Overview ¶
Package web 一个微型的 RESTful API 框架
Index ¶
Constants ¶
View Source
const Version = "0.40.0"
Version 当前框架的版本
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
func NewContext ¶
func NewContext(w http.ResponseWriter, r *http.Request) *Context
NewContext 构建 *Context 实例
type HandlerFunc ¶ added in v0.33.0
type HandlerFunc = server.HandlerFunc
type Server ¶ added in v0.25.0
func DefaultServer ¶ added in v0.39.0
DefaultServer 返回一个采用默认值进初始化的 *Server 实例
func LoadServer ¶ added in v0.39.0
LoadServer 从配置文件加载并实例化 Server 对象
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
web
module
|
|
|
Package config 提供了从配置文件初始化 Server 的方法
|
Package config 提供了从配置文件初始化 Server 的方法 |
|
Package content 与生成内容相关的功能
|
Package content 与生成内容相关的功能 |
|
form
Package form 用于处理 www-form-urlencoded 编码 func read(ctx *web.Context) { vals := urls.Values{} ctx.Read(vals) } func write(ctx *web.Context) { vals := urls.Values{} vals.Add("name", "caixw") ctx.Render(http.StatusOK, vals, nil) } form 用户可以通过定义 form 标签自定义输出的名称,比如: type Username struct { Name string `form:"name"` Age int } 转换成 form-data 可能是以下样式: name=jjj&age=18 该方式对数据类型有一定限制: 1.
|
Package form 用于处理 www-form-urlencoded 编码 func read(ctx *web.Context) { vals := urls.Values{} ctx.Read(vals) } func write(ctx *web.Context) { vals := urls.Values{} vals.Add("name", "caixw") ctx.Render(http.StatusOK, vals, nil) } form 用户可以通过定义 form 标签自定义输出的名称,比如: type Username struct { Name string `form:"name"` Age int } 转换成 form-data 可能是以下样式: name=jjj&age=18 该方式对数据类型有一定限制: 1. |
|
gob
Package gob 提供 GOB 格式的编解码
|
Package gob 提供 GOB 格式的编解码 |
|
html
Package html 提供输出 HTML 内容的 content.MarshalFunc 函数 mt := content.NewContent() tpl := template.ParseFiles(...) mgr := html.New(tpl) mt.Add("text/html", mgr.Marshal, nil) func handle(ctx *web.Context) { ctx.Render(200, html.Tpl("index", map[string]interface{}{...}), nil) }
|
Package html 提供输出 HTML 内容的 content.MarshalFunc 函数 mt := content.NewContent() tpl := template.ParseFiles(...) mgr := html.New(tpl) mt.Add("text/html", mgr.Marshal, nil) func handle(ctx *web.Context) { ctx.Render(200, html.Tpl("index", map[string]interface{}{...}), nil) } |
|
text
Package text 针对文本内容的编解码实现
|
Package text 针对文本内容的编解码实现 |
|
text/testobject
Package testobject 用于测试 mimetype 的对象
|
Package testobject 用于测试 mimetype 的对象 |
|
internal
|
|
|
charsetdata
Package charsetdata 用于测试的字符集数据
|
Package charsetdata 用于测试的字符集数据 |
|
filesystem
Package filesystem 提供与文件系统相关的操作
|
Package filesystem 提供与文件系统相关的操作 |
|
plugintest
Package plugintest 作为插件的功能测试包 NOTE: 该测试如果直接写在功能所在的包,目前版本会报错。
|
Package plugintest 作为插件的功能测试包 NOTE: 该测试如果直接写在功能所在的包,目前版本会报错。 |
|
Package server web 服务管理
|
Package server web 服务管理 |
|
Package service 服务管理
|
Package service 服务管理 |
Click to show internal directories.
Click to hide internal directories.