跳到主要内容
知仓学习社ZHICANG

go-http-server-applications

Design, build, test, and review production Go HTTP servers covering inbound adapters, modern ServeMux routing, middleware, strict bounded request de…

不碰外部(只输出文字)无严重或高危命中hashgraph-online/awesome-codex-plugins

它会碰到什么

扫了多少8 个文本文件,11 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

Go HTTP Server Applications

Keep handlers thin, bound untrusted input, configure the server explicitly, and

make startup and shutdown part of the tested application contract.

Core Workflow

  1. Separate domain behavior from the inbound HTTP adapter.
  2. Define routes, methods, media types, limits, and error mappings.
  3. Build an explicit mux and ordered middleware stack.
  4. Decode requests strictly and within endpoint-specific byte/time budgets.
  5. Encode complete responses before committing headers where practical.
  6. Configure listener, server timeouts, header limits, and health semantics.
  7. Serve under a lifecycle that observes errors and drains with a deadline.
  8. Test handlers, routing, middleware, shared state, and real loopback behavior.

Read Next

| Task | Load |

|---|---|

| Build a server | guidelines.md, workflows/build-http-server.md |

| Test handlers or lifecycle | workflows/test-http-server.md |

| Review routing, middleware, JSON, or shutdown | references/http-server/rules.md |

| Understand server and writer contracts | references/http-server/knowledge.md |

| Review patterns | references/http-server/examples.md |

Guardrails

  • Do not use http.DefaultServeMux for application composition.
  • Do not expose a public server with zero-value timeout policy by accident.
  • Do not read request bodies without an endpoint-specific bound.
  • Do not assume a wrapped ResponseWriter preserves optional capabilities.
  • Do not call readiness an unconditional liveness response.
  • Do not let the process exit before graceful shutdown finishes.

Source Notes

Guidance is transformed and paraphrased from Inanc Gumus, *Go by Example:

Programmer's Guide to Idiomatic and Testable Programs* (Manning, 2025),

Chapters 8-9. Examples are original.

Terminal-response control-flow and timeout guidance also incorporates

transformed material from Teiva Harsanyi, *100 Go Mistakes and How to Avoid

Them* (Manning, 2022), Chapter 10.

Book: https://www.manning.com/books/go-by-example

Verify current routing and lifecycle behavior against https://pkg.go.dev/net/http

and https://pkg.go.dev/net/http/httptest for the pinned Go version.

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。