🎨 加入只读模式配置

This commit is contained in:
Liang Ding 2022-08-09 10:05:05 +08:00
parent 9076912b9d
commit 58611c8f1e
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
1 changed files with 6 additions and 0 deletions

View File

@ -24,11 +24,17 @@ import (
"strings" "strings"
"github.com/88250/gulu" "github.com/88250/gulu"
"github.com/88250/wide/conf"
"github.com/88250/wide/session" "github.com/88250/wide/session"
) )
// AutocompleteHandler handles request of code autocompletion. // AutocompleteHandler handles request of code autocompletion.
func AutocompleteHandler(w http.ResponseWriter, r *http.Request) { func AutocompleteHandler(w http.ResponseWriter, r *http.Request) {
if conf.Wide.ReadOnly {
http.Error(w, "Forbidden", http.StatusForbidden)
return
}
var args map[string]interface{} var args map[string]interface{}
if err := json.NewDecoder(r.Body).Decode(&args); err != nil { if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
logger.Error(err) logger.Error(err)