add readme
This commit is contained in:
parent
c027ef22bc
commit
0d0477d32c
47
README.md
47
README.md
|
@ -4,5 +4,52 @@
|
|||
|
||||
|
||||
|
||||
# 环境变量
|
||||
|
||||
| 环境变量 | 描述 |
|
||||
| --- | --- |
|
||||
| AEUS_DEBUG | 是否开启debug模式 |
|
||||
| HTTP_PORT | http服务端口 |
|
||||
| GRPC_PORT | grpc服务端口 |
|
||||
| CLI_PORT | cli服务端口 |
|
||||
|
||||
|
||||
# 快速开始
|
||||
|
||||
## 创建一个项目
|
||||
|
||||
创建项目可以使用`aeus`命令行工具进行生成:
|
||||
|
||||
```
|
||||
aeus new github.com/your-username/your-project-name
|
||||
```
|
||||
|
||||
如果需要创建一个带管理后台的应用, 可以使用`--admin`参数:
|
||||
|
||||
```
|
||||
aeus new github.com/your-username/your-project-name --admin
|
||||
```
|
||||
|
||||
|
||||
## 生成`Proto`文件
|
||||
|
||||
服务使用`proto3`作为通信协议,因此需要生成`Proto`文件。
|
||||
|
||||
```
|
||||
make proto
|
||||
```
|
||||
|
||||
清理生成的文件使用:
|
||||
|
||||
```
|
||||
make proto-clean
|
||||
```
|
||||
|
||||
## 编译项目
|
||||
|
||||
编译项目可以使用`make`命令进行编译:
|
||||
|
||||
```
|
||||
make build
|
||||
```
|
||||
|
||||
|
|
2
app.go
2
app.go
|
@ -122,7 +122,7 @@ func (s *Service) injectVars(v any) {
|
|||
}
|
||||
|
||||
func (s *Service) preStart(ctx context.Context) (err error) {
|
||||
s.Logger().Info(s.ctx, "starting")
|
||||
s.Logger().Info(ctx, "starting")
|
||||
for _, ptr := range s.opts.servers {
|
||||
s.refValues = append(s.refValues, reflect.ValueOf(ptr))
|
||||
}
|
||||
|
|
|
@ -47,7 +47,13 @@ func WithAllow(paths ...string) Option {
|
|||
if o.allows == nil {
|
||||
o.allows = make([]string, 0, 16)
|
||||
}
|
||||
o.allows = append(o.allows, paths...)
|
||||
for _, s := range paths {
|
||||
s = strings.TrimSpace(s)
|
||||
if len(s) == 0 {
|
||||
continue
|
||||
}
|
||||
o.allows = append(o.allows, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,19 +71,19 @@ func WithValidate(fn Validate) Option {
|
|||
|
||||
// isAllowed check if the path is allowed
|
||||
func isAllowed(uripath string, allows []string) bool {
|
||||
for _, str := range allows {
|
||||
n := len(str)
|
||||
if n == 0 {
|
||||
continue
|
||||
for _, pattern := range allows {
|
||||
n := len(pattern)
|
||||
if pattern == uripath {
|
||||
return true
|
||||
}
|
||||
if n > 1 && str[n-1] == '*' {
|
||||
if strings.HasPrefix(uripath, str[:n-1]) {
|
||||
if pattern == "*" {
|
||||
return true
|
||||
}
|
||||
if n > 1 && pattern[n-1] == '*' {
|
||||
if strings.HasPrefix(uripath, pattern[:n-1]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if str == uripath {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue