git clone https://github.com/shijiaoliang/go-sensitive.git
cd path/go-sensitive
go mod tidy
cd path/go-sensitive/api
go run sensitive.go -f etc/sensitive-api.yaml
- 路由定义
- Url: /sensitive/validate
- Method: POST
- Request:
ValidateReq - Response:
ValidateReply
- 请求定义
type ValidateReq struct {
Txt string `json:"txt"`
Hash string `json:"hash,optional"`
}- 返回定义
type ValidateReply struct {
IsValidate bool `json:"is_validate"`
BadWord string `json:"bad_word"`
}- 路由定义
- Url: /sensitive/find
- Method: POST
- Request:
FindReq - Response:
FindReply
- 请求定义
type FindReq struct {
Txt string `json:"txt"`
Channel string `json:"channel"`
Hash string `json:"hash,optional"`
}- 返回定义
type FindReply struct {
IsValidate bool `json:"is_validate"`
BadWords map[string][]string `json:"bad_words"`
}- 路由定义
- Url: /sensitive/batch-find
- Method: POST
- Request:
BatchFindReq - Response:
BatchFindReply
- 请求定义
type BatchFindReq struct {
Items []BatchItemReq `json:"items"`
}- 返回定义
type BatchFindReply struct {
Items map[string]BatchItemReply `json:"items"`
}- 路由定义
- Url: /sensitive/add-word
- Method: POST
- Request:
AddWordReq - Response:
AddWordReply
- 请求定义
type AddWordReq struct {
Words []string `json:"words"`
}- 返回定义
type AddWordReply struct {
}- 路由定义
- Url: /sensitive/delete-word
- Method: POST
- Request:
DeleteWordReq - Response:
DeleteWordReply
- 请求定义
type DeleteWordReq struct {
Words []string `json:"words"`
}- 返回定义
type DeleteWordReply struct {
}