12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- /*
- * @Descripttion:敏感词
- * @version:
- * @Author: Neo,Huang
- * @Date: 2021-04-17 11:04:16
- * @LastEditors: Neo,Huang
- * @LastEditTime: 2021-04-20 09:52:10
- */
- package sensitive
- import (
- "encoding/json"
- "net/http"
- )
- // 初始化
- func Init() {
- InitDFA()
- }
- // 敏感词检查
- // 方法:get
- // 参数:
- // word:检查字符串
- // 返回
- // true/false
- func HttpCheckWord(w http.ResponseWriter, r *http.Request) {
- req := r.URL.Query()
- word := req.Get("word")
- cw := CheckSensitive(word, sensitiveWord)
- // 发送成功
- w.Write([]byte(cw))
- }
- // 敏感词检查
- // 方法:get
- // 参数:
- // word:检查字符串
- // 返回
- // true/false
- func HttpChangeWord(w http.ResponseWriter, r *http.Request) {
- req := r.URL.Query()
- word := req.Get("word")
- ret := make(map[string]string)
- ret["word"] = ChangeSensitiveWords(word, sensitiveWord)
- pack, _ := json.Marshal(ret)
- // 发送成功
- w.Write(pack)
- }
|