Skip to content

Commit

Permalink
docs: 补充一些信息
Browse files Browse the repository at this point in the history
  • Loading branch information
afzw committed Mar 24, 2024
1 parent 8955704 commit 091a4ab
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ jobs:
- name: Install
run: go install github.com/swaggo/swag/cmd/swag@latest

# 生成swag信息
# build项目
- name: Build
run: swag init && go build
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

基于属性的权限验证(ABAC,Attribute-Based Access Control)的微服务,为其他业务服务提供权限认证。

## 参考
https://github.com/marmotedu/iam/tree/v1.0.0

- [go swagg api文档](https://github.com/swaggo/swag/blob/master/README_zh-CN.md#%E5%A3%B0%E6%98%8E%E5%BC%8F%E6%B3%A8%E9%87%8A%E6%A0%BC%E5%BC%8F)

## 快速开始

Expand All @@ -17,6 +14,22 @@ https://github.com/marmotedu/iam/tree/v1.0.0
air
```

- 查看接口文档
> air启动后需要过一段时间才可以终止程序(立即`CTRL+C`后,程序可能仍然运行)。
- 获取/查看接口文档

拉取项目后,安装[go swag](https://github.com/swaggo/gin-swagger)组件,执行以下命令生成swag文档。

```sh
swag init
```

然后可以**在debug模式下**前往http://<BaseUrl>/swagger/index.html查看。



## 参考

- [企业级的 Go 语言实战项目:认证和授权系统](https://github.com/marmotedu/iam/tree/v1.0.0)

跑起项目后,前往http://<BaseUrl>/swagger/index.html查看。
- [go swag api文档](https://github.com/swaggo/swag/blob/master/README_zh-CN.md#%E5%A3%B0%E6%98%8E%E5%BC%8F%E6%B3%A8%E9%87%8A%E6%A0%BC%E5%BC%8F)
16 changes: 10 additions & 6 deletions router/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"auth-server/config"
"auth-server/docs"
"auth-server/middleware"
"strconv"

swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"strconv"

"github.com/gin-gonic/contrib/sessions"

Expand All @@ -29,7 +30,10 @@ func InitRouter() {
engine := gin.New()
engine.Use(gin.Recovery())

engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
if config.DebugMode {
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
}

docs.SwaggerInfo.BasePath = "/api/v1"

// session 设置
Expand All @@ -46,11 +50,11 @@ func InitRouter() {
// 登陆认证相关路由
authRouterGroup := engine.Group("/auth")
authRouter(authRouterGroup)
// 用户登陆
userRouterGroup := engine.Group("/api/v1")
userRouterGroup.Use(middleware.SessionAuth())
// 业务路由
serviceRouterGroup := engine.Group("/api/v1")
serviceRouterGroup.Use(middleware.SessionAuth())
userRouter(serviceRouterGroup)

userRouter(userRouterGroup)
port := config.ServerPort
runParams := config.ServerHost + ":" + strconv.Itoa(port)
log.Println("master server at ", runParams)
Expand Down

0 comments on commit 091a4ab

Please sign in to comment.