default.go 787 字节
Newer Older
E
eoLinker API Management 已提交
1 2 3 4
package discovery

import (
	"fmt"
Y
Your Name 已提交
5
	"github.com/eolinker/goku-api-gateway/console/controller"
E
eoLinker API Management 已提交
6 7
	"net/http"

黄孟柱 已提交
8
	"github.com/eolinker/goku-api-gateway/console/module/service"
E
eoLinker API Management 已提交
9 10 11 12
)

func setDefault(w http.ResponseWriter, r *http.Request) {

Y
Your Name 已提交
13 14

	if err := r.ParseForm() ; err!= nil{
E
eoLinker API Management 已提交
15 16 17 18 19 20 21 22 23
		controller.WriteError(w, "260000", "data", "[param_check] Parse form body error | 解析form表单参数错误", err)
		return
	}
	name := r.FormValue("name")
	if !service.ValidateName(name) {
		controller.WriteError(w, "260000", "data", fmt.Sprintf("[param_check] invalid  [name]"), nil)
		return
	}

Y
Your Name 已提交
24
	err := service.SetDefaut(name)
E
eoLinker API Management 已提交
25 26 27 28 29 30 31 32 33 34
	if err != nil {
		controller.WriteError(w, "260000", "data", fmt.Sprintf("[error] %s", err.Error()), err)
		return
	}

	controller.WriteResultInfo(w,
		"data",
		"data",
		nil)
}