Skip to content

Commit

Permalink
Update README.MD
Browse files Browse the repository at this point in the history
  • Loading branch information
soonio authored Dec 2, 2021
1 parent a458ce1 commit 05b608e
Showing 1 changed file with 4 additions and 85 deletions.
89 changes: 4 additions & 85 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,88 +1,7 @@
# swagger服务
# swagger

## 依赖
## 直接下载包获取dist目录中的文件替换index.html即可

- [go-frame](https://goframe.org)
https://github.com/swagger-api/swagger-ui/releases

## 安装构建

```
go mod tidy
gf build main.go
mv bin/linux_amd64/swg /var/www/matrix
mv resource/index.html /var/www/matrix
```
## 目录结构
```bash
[root@localhost swagger]# tree
.
├── index.html
├── runtime
│   └── server
│   └── 2021-05-26.log
├── swagger
│   └── swagger.json
└── swg
3 directories, 4 files
```
## 基于supervisor进程守护
```ini
[program:swg]
directory=/var/www/matrix
command=/var/www/matrix/swg
user=root
autostart=true
autorestart=true
startsecs=3
startretries=3
stderr_logfile=/var/log/supervisor/swg-err.log
stdout_logfile=/var/log/supervisor/swg-out.log
```
## nginx代理
```nginx configuration
server {
listen 80;
server_name swagger.domain-example.com;
client_max_body_size 10m;
location / {
proxy_pass http://127.0.0.1:8009;
proxy_read_timeout 30s;
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```
## 如果需要配置swagger密码
```go
// router/router.go
package router
import (
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/swagger"
"swagger/app/api"
)
func init() {
s := g.Server()
s.Group("/", func(group *ghttp.RouterGroup) {
group.ALL("/", api.Hello)
})
s.Plugin(&swagger.Swagger{
BasicAuthUser: "username-placeholder",
BasicAuthPass: "password-placeholder",
})
}
```
## 修改index.html中的内容

0 comments on commit 05b608e

Please sign in to comment.