Go 微服务开发实用指南
1. 不同内容类型请求测试
在单独的终端中,运行以下命令:
$ curl "http://localhost:3333" -H "Content-Type: text/xml"
$ curl "http://localhost:3333" -H "Content-Type: application/json"
你应该会看到以下输出:
$ curl "http://localhost:3333" -H "Content-Type: text/xml"
<payload><status>Successful!</status></payload>
$ curl "http://localhost:3333" -H "Content-Type: application/json"
{"status":"Successful!"}
顶级目录中 go.mod 文件可能会更新,并且应该会出现 go.sum 文件。如果复制或编写了自己的测试代码,进入上一级目录并运行 go test ,确保所有测试都通过。
原理
github.com/unrolled/render 包在这个过程中起到了关键作用。当处理 HTML 模板等内容时,还有许多其他选项可以配置。通过传递不同的内容类
超级会员免费看
订阅专栏 解锁全文
1066

被折叠的 条评论
为什么被折叠?



