-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## 0.2.0-beta5 增加@alias+从json读取access/request配置
- Loading branch information
Showing
15 changed files
with
108 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/samber/lo" | ||
"net/http" | ||
|
||
"github.com/samber/lo" | ||
) | ||
|
||
type QueryConfig struct { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ const ( | |
Count = "count" // page size | ||
Total = "total" | ||
Query = "query" | ||
Alias = "@alias" | ||
) | ||
|
||
const ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package config | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/glennliao/apijson-go/config" | ||
"github.com/gogf/gf/v2/util/gconv" | ||
) | ||
|
||
func RequestListProvider(ctx context.Context, jsonStr string) config.RequestListProvider { | ||
|
||
return func(ctx context.Context) []config.RequestConfig { | ||
var requestList []config.RequestConfig | ||
err := gconv.Scan(jsonStr, &requestList) | ||
if err != nil { | ||
panic(err) | ||
} | ||
for i, request := range requestList { | ||
if _, ok := request.Structure[request.Tag]; !ok { | ||
requestList[i].Structure = map[string]*config.Structure{ | ||
request.Tag: { | ||
Must: nil, | ||
Refuse: nil, | ||
Unique: nil, | ||
Insert: nil, | ||
Update: nil, | ||
Replace: nil, | ||
Remove: nil, | ||
}, | ||
} | ||
} | ||
} | ||
return requestList | ||
} | ||
|
||
} | ||
|
||
func AccessListProvider(ctx context.Context, jsonStr string) config.AccessListProvider { | ||
return func(ctx context.Context) []config.AccessConfig { | ||
var accessList []config.AccessConfig | ||
err := gconv.Scan(jsonStr, &accessList) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return accessList | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters