3 Star 3 Fork 0

Gitee 极速下载 / go-restful

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/emicklei/go-restful
克隆/下载
doc_examples_test.go 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
Ernest Micklei 提交于 2015-09-28 09:51 . update docs
package restful
import "net/http"
func ExampleOPTIONSFilter() {
// Install the OPTIONS filter on the default Container
Filter(OPTIONSFilter())
}
func ExampleContainer_OPTIONSFilter() {
// Install the OPTIONS filter on a Container
myContainer := new(Container)
myContainer.Filter(myContainer.OPTIONSFilter)
}
func ExampleContainer() {
// The Default container of go-restful uses the http.DefaultServeMux.
// You can create your own Container using restful.NewContainer() and create a new http.Server for that particular container
ws := new(WebService)
wsContainer := NewContainer()
wsContainer.Add(ws)
server := &http.Server{Addr: ":8080", Handler: wsContainer}
server.ListenAndServe()
}
func ExampleCrossOriginResourceSharing() {
// To install this filter on the Default Container use:
cors := CrossOriginResourceSharing{ExposeHeaders: []string{"X-My-Header"}, CookiesAllowed: false, Container: DefaultContainer}
Filter(cors.Filter)
}
func ExampleServiceError() {
resp := new(Response)
resp.WriteEntity(NewError(http.StatusBadRequest, "Non-integer {id} path parameter"))
}
func ExampleBoundedCachedCompressors() {
// Register a compressor provider (gzip/deflate read/write) that uses
// a bounded cache with a maximum of 20 writers and 20 readers.
SetCompressorProvider(NewBoundedCachedCompressors(20, 20))
}
Go
1
https://gitee.com/mirrors/go-restful.git
git@gitee.com:mirrors/go-restful.git
mirrors
go-restful
go-restful
v3

搜索帮助