[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-10872":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":16,"starSnapshotCount":16,"syncStatus":33,"lastSyncTime":34,"discoverSource":35},10872,"alice","justinas\u002Falice","justinas","Painless middleware chaining for Go","https:\u002F\u002Fgodoc.org\u002Fgithub.com\u002Fjustinas\u002Falice",null,"Go",3361,152,47,4,0,3,8,1,28.55,"MIT License",false,"master",true,[26,27,28,29],"go","handler","middleware","web","2026-06-12 02:02:27","# Alice \n\n[![GoDoc](https:\u002F\u002Fgodoc.org\u002Fgithub.com\u002Fgolang\u002Fgddo?status.svg)](http:\u002F\u002Fgodoc.org\u002Fgithub.com\u002Fjustinas\u002Falice)\n[![Build Status](https:\u002F\u002Ftravis-ci.org\u002Fjustinas\u002Falice.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002Fjustinas\u002Falice)\n[![Coverage](http:\u002F\u002Fgocover.io\u002F_badge\u002Fgithub.com\u002Fjustinas\u002Falice)](http:\u002F\u002Fgocover.io\u002Fgithub.com\u002Fjustinas\u002Falice)\n\nAlice provides a convenient way to chain \nyour HTTP middleware functions and the app handler.\n\nIn short, it transforms\n\n```go\nMiddleware1(Middleware2(Middleware3(App)))\n```\n\nto\n\n```go\nalice.New(Middleware1, Middleware2, Middleware3).Then(App)\n```\n\n### Why?\n\nNone of the other middleware chaining solutions\nbehaves exactly like Alice.\nAlice is as minimal as it gets:\nin essence, it's just a for loop that does the wrapping for you.\n\nCheck out [this blog post](http:\u002F\u002Fjustinas.org\u002Falice-painless-middleware-chaining-for-go\u002F)\nfor explanation how Alice is different from other chaining solutions.\n\n### Usage\n\nYour middleware constructors should have the form of\n\n```go\nfunc (http.Handler) http.Handler\n```\n\nSome middleware provide this out of the box.\nFor ones that don't, it's trivial to write one yourself.\n\n```go\nfunc myStripPrefix(h http.Handler) http.Handler {\n    return http.StripPrefix(\"\u002Fold\", h)\n}\n```\n\nThis complete example shows the full power of Alice.\n\n```go\npackage main\n\nimport (\n    \"net\u002Fhttp\"\n    \"time\"\n\n    \"github.com\u002Fthrottled\u002Fthrottled\"\n    \"github.com\u002Fjustinas\u002Falice\"\n    \"github.com\u002Fjustinas\u002Fnosurf\"\n)\n\nfunc timeoutHandler(h http.Handler) http.Handler {\n    return http.TimeoutHandler(h, 1*time.Second, \"timed out\")\n}\n\nfunc myApp(w http.ResponseWriter, r *http.Request) {\n    w.Write([]byte(\"Hello world!\"))\n}\n\nfunc main() {\n    th := throttled.Interval(throttled.PerSec(10), 1, &throttled.VaryBy{Path: true}, 50)\n    myHandler := http.HandlerFunc(myApp)\n\n    chain := alice.New(th.Throttle, timeoutHandler, nosurf.NewPure).Then(myHandler)\n    http.ListenAndServe(\":8000\", chain)\n}\n```\n\nHere, the request will pass [throttled](https:\u002F\u002Fgithub.com\u002FPuerkitoBio\u002Fthrottled) first,\nthen an http.TimeoutHandler we've set up,\nthen [nosurf](https:\u002F\u002Fgithub.com\u002Fjustinas\u002Fnosurf)\nand will finally reach our handler.\n\nNote that Alice makes **no guarantees** for\nhow one or another piece of  middleware will behave.\nOnce it passes the execution to the outer layer of middleware,\nit has no saying in whether middleware will execute the inner handlers.\nThis is intentional behavior.\n\nAlice works with Go 1.0 and higher.\n\n### Contributing\n\n0. Find an issue that bugs you \u002F open a new one.\n1. Discuss.\n2. Branch off, commit, test.\n3. Make a pull request \u002F attach the commits to the issue.\n","justinas\u002Falice 是一个用于 Go 语言的 HTTP 中间件链式调用库。它通过简洁的 API 将多个中间件与最终的应用处理器串联起来，使得代码更加清晰易读。Alice 的核心功能是将复杂的嵌套调用转换为简单的链式调用，极大简化了中间件的使用方式。此外，Alice 遵循极简设计原则，几乎不引入额外开销。适用于需要高效处理 HTTP 请求并希望以模块化方式管理中间件的 Web 应用场景，尤其适合那些追求代码简洁性和可维护性的开发者。",2,"2026-06-11 03:30:35","top_topic"]