command
Version:
v0.0.0-...-31e44ea
Opens a new window with list of versions in this module.
Published: Jan 22, 2022
License: MIT
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
用户名微服务
功能:传入用户的ID,先从数据库查找,如果找到了就返回用户名,找不到就返回“游客”
相比于z05_username案例,这里升级路由,使其支持REST API风格。另外,transport层在解析前端参数的时候,也改进了获取路径参数的方法。
参考文档:https://github.com/gorilla/mux#examples
目录结构
- main.go:项目入口
- service:服务层,用于定义微服务的接口和编写实现类
- endpoint:端点层,用于定义Request和Response格式,以及各种中间件。每个方法都有自己的Request和Response
- transport:传输协议层,主要负责与http, grpc, thrift等相关的逻辑。一般会有处理用户输入的解码方法和处理返回给客户响应的编码方法
运行程序
go run examples/z06_username/main.go
访问测试
Documentation
¶
There is no documentation for this package.
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.