Skip to content

shijiaoliang/go-sensitive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

敏感词服务


运行

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

API

1. "验证是否包含敏感词"

  1. 路由定义
  • Url: /sensitive/validate
  • Method: POST
  • Request: ValidateReq
  • Response: ValidateReply
  1. 请求定义
type ValidateReq struct {
	Txt string `json:"txt"`
	Hash string `json:"hash,optional"`
}
  1. 返回定义
type ValidateReply struct {
	IsValidate bool `json:"is_validate"`
	BadWord string `json:"bad_word"`
}

2. "查找所有敏感词"

  1. 路由定义
  • Url: /sensitive/find
  • Method: POST
  • Request: FindReq
  • Response: FindReply
  1. 请求定义
type FindReq struct {
	Txt string `json:"txt"`
	Channel string `json:"channel"`
	Hash string `json:"hash,optional"`
}
  1. 返回定义
type FindReply struct {
	IsValidate bool `json:"is_validate"`
	BadWords map[string][]string `json:"bad_words"`
}

3. "批量查找所有敏感词"

  1. 路由定义
  • Url: /sensitive/batch-find
  • Method: POST
  • Request: BatchFindReq
  • Response: BatchFindReply
  1. 请求定义
type BatchFindReq struct {
	Items []BatchItemReq `json:"items"`
}
  1. 返回定义
type BatchFindReply struct {
	Items map[string]BatchItemReply `json:"items"`
}

4. "批量新增敏感词"

  1. 路由定义
  • Url: /sensitive/add-word
  • Method: POST
  • Request: AddWordReq
  • Response: AddWordReply
  1. 请求定义
type AddWordReq struct {
	Words []string `json:"words"`
}
  1. 返回定义
type AddWordReply struct {
}

5. "批量删除敏感词"

  1. 路由定义
  • Url: /sensitive/delete-word
  • Method: POST
  • Request: DeleteWordReq
  • Response: DeleteWordReply
  1. 请求定义
type DeleteWordReq struct {
	Words []string `json:"words"`
}
  1. 返回定义
type DeleteWordReply struct {
}

preview

image

About

高性能Go敏感词服务

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages