Coder Social home page Coder Social logo

go-sensitive's Introduction

敏感词服务


运行

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

go-sensitive's People

Contributors

shijiaoliang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.