master
Could not load branches
Nothing to show
Could not load tags
Nothing to show
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
1
branch
0
tags
Code
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
1. 采用docker swarm + hub 的方式部署(目前实现的)
2. 采用k8s + hub 的方式部署(预留)
api -- 存放protobuf相关文件 供client和server通信调用
cmd -- 可执行程序的入口(可以有多个可执行程序,每一个的main函数都在子文件夹)
configs -- 项目配置文件(可以对应多个可执行程序有多个配置文件)
internal -- 包含app和pkg
app -- 项目的逻辑代码,包含controllers repositories services
pkg -- 通用的代码,项目的公共代码
vendor -- 项目依赖包/库
.gitignore -- git忽略文件列表
.dockerignore -- docker忽略文件列表
Dockerfile -- docker镜像配置文件
docker-compose.yml -- docker-compose配置文件(已gitignore 直接在protainer中配置)
go.mod -- 项目依赖的第三方包
go.sum -- 所有依赖的包
Makefile -- 执行脚本的Makefile文件
README.md -- 说明文档
golang >= 1.13
1. cd community-blogger
2. cp /configs/home.yaml.example home.yaml
3. cp /configs/article.yaml.example article.yaml
4. ./dist/manage -f configs/home.yaml
5. ./dist/manage -f configs/article.yaml
6. 与上述步骤类似,此处省略 ...
1. cd community-blogger
2. go list ./... | grep -v /vendor/ | xargs -L1 golint -set_exit_status
cd community-blogger/internal/app/article/repositories
go test -v
go test -cover
调用rpc服务获取用户信息 JWT认证
GET http://127.0.0.1:8004/api/v1/user?id=1
herders: Authorization eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTc4MjYwMzR9.BrcFgcv8GMYxDlR7QU3U0EDd9UbmaSVwaKKOaydHgus
{
"data": {
"id": 1,
"username": "aaa3",
"token": "553f5acf-d370-4bda-9ccd-ac8eb64e9665"
}
}
CSRF TOKEN 认证
GET http://127.0.0.1:8001/protected
{
"csrf_token": "pZsqS3IJf5J-fejsO6ikdR6aXyw="
}
带csrf_token请求:
headers key:X-CSRF-TOKEN value:pZsqS3IJf5J-fejsO6ikdR6aXyw=