您的位置 首页 golang

Golang 开发 http 的 server 和 client

http 服务器

启动服务器

 $ go run demo/base/http/server/server.go
2021/05/31 22:26:35 starting httpserver at http:localhost:1210  

使用 浏览器 或者 命令行测试一下:

如上所示:这就是我们服务端返回的内容 hello hello, this is httpserver

http 客户端

为什么需要客户端

在多项目、微服务的场景下,项目服务之间的互相通信并不像。使用浏览器、命令行输入域名返回结果。所以需要自己编写发起 http 请求的客户端,实现项目服务之间的通信

运行服务测试一下 go run demo/base/http/server/server.go ,返回 服务端响应内容 hello hello, this is httpserver

References

[1] 更多往期文章在我的个人博客:

文章来源:智云一二三科技

文章标题:Golang 开发 http 的 server 和 client

文章地址:https://www.zhihuclub.com/86765.shtml

关于作者: 智云科技

热门文章

网站地图