dmskys / go-sensitive

高性能Go敏感词服务

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

敏感词服务


运行

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 {
}

image

About

高性能Go敏感词服务

License:MIT License


Languages

Language:Go 100.0%