示例

原文:https://github.com/go-chi/chi/blob/master/_examples/README.md

chi examples chi 示例

  • custom-handler - Use a custom handler function signature custom-handler - 使用自定义处理程序函数签名
  • custom-method - Add a custom HTTP method custom-method - 添加自定义 HTTP 方法
  • fileserver - Easily serve static files fileserver - 轻松提供静态文件
  • graceful - Graceful context signaling and server shutdown graceful - 优雅的上下文信令和服务器关闭
  • hello-world - Hello World!
  • limits - Timeouts and Throttling 限制 - 超时和节流
  • logging - Easy structured logging for any backend 日志记录 - 适用于任何后端的简单结构化日志记录
  • rest - REST APIs made easy, productive and maintainable rest - REST API 简便、高效且易于维护
  • router-walk - Print to stdout a router’s routes router-walk - 将路由器的路由打印到 stdout
  • todos-resource - Struct routers/handlers, an example of another code layout style todos-resource - 结构路由器/处理程序,另一个代码布局样式的示例
  • versions - Demo of chi/render subpkg 版本 - chi/render 子包的演示

Usage 用法

  1. go get -v -d -u ./... - fetch example deps 获取示例依赖项
  2. cd <example>/ ie. cd rest/
  3. go run *.go - note, example services run on port 3333 注意,示例服务在端口 3333 上运行
  4. Open another terminal and use curl to send some requests to your example service, curl -v http://localhost:3333/ 打开另一个终端并使用 curl 向示例服务发送一些请求, curl -v http://localhost:3333/
  5. Read /main.go source to learn how service works and read comments for usage 阅读 /main.go 源代码以了解服务的工作原理并阅读用法注释
最后修改 October 10, 2024: 更新 (a4b8f85)