handlers

A collection of useful handlers for Go's net/http package.

Github星跟踪图

gorilla/handlers

GoDoc
CircleCI
Sourcegraph

Package handlers is a collection of handlers (aka "HTTP middleware") for use
with Go's net/http package (or any framework supporting http.Handler), including:

Other handlers are documented on the Gorilla
website
.

Example

A simple example using handlers.LoggingHandler and handlers.CompressHandler:

import (
    "net/http"
    "github.com/gorilla/handlers"
)

func main() {
    r := http.NewServeMux()

    // Only log requests to our admin dashboard to stdout
    r.Handle("/admin", handlers.LoggingHandler(os.Stdout, http.HandlerFunc(ShowAdminDashboard)))
    r.HandleFunc("/", ShowIndex)

    // Wrap our server with our gzip handler to gzip compress all responses.
    http.ListenAndServe(":8000", handlers.CompressHandler(r))
}

License

BSD licensed. See the included LICENSE file for details.

主要指标

概览
名称与所有者gorilla/handlers
主编程语言Go
编程语言Go (语言数: 2)
平台
许可证BSD 3-Clause "New" or "Revised" License
所有者活动
创建于2013-02-01 03:53:49
推送于2024-02-20 16:27:20
最后一次提交
发布数10
最新版本名称v1.5.2 (发布于 )
第一版名称v1.1 (发布于 )
用户参与
星数1.7k
关注者数28
派生数274
提交数198
已启用问题?
问题数122
打开的问题数16
拉请求数81
打开的拉请求数6
关闭的拉请求数53
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?