lijian 1 rok pred
rodič
commit
4cb6a7c0d0

+ 1 - 1
services/knowoapi/controllers/errorresponse.go

@@ -43,5 +43,5 @@ func done(ctx iris.Context, result interface{}) {
 }
 
 func badRequest(ctx iris.Context, err error) {
-	fail(ctx, iris.StatusBadRequest, "错误:%s", err.Error())
+	fail(ctx, iris.StatusBadRequest, "请求参数错误:%s", err.Error())
 }

+ 1 - 3
services/knowoapi/controllers/user.go

@@ -1,7 +1,6 @@
 package controllers
 
 import (
-	"fmt"
 	"sparrow/pkg/models"
 	"sparrow/pkg/server"
 	"sparrow/services/knowoapi/model"
@@ -18,8 +17,7 @@ type UserController struct {
 }
 
 // PostLogin /login
-func (a *UserController) PostLogin(req models.LoginRequest) {
-	fmt.Println(req.UserName)
+func (a *UserController) PostLogin() {
 	lr := models.LoginRequest{}
 	if err := parseBody(a.Ctx, &lr); err != nil {
 		badRequest(a.Ctx, err)

+ 1 - 0
services/knowoapi/main.go

@@ -32,6 +32,7 @@ func main() {
 
 func newApp() *iris.Application {
 	app := iris.New()
+	iris.WithoutBodyConsumptionOnUnmarshal(app)
 	app.AllowMethods(iris.MethodOptions)
 	registerErrors(app)
 	db, err := getDB()

+ 1 - 11
services/knowoapi/router.go

@@ -8,8 +8,6 @@ import (
 	"sparrow/services/knowoapi/model"
 	"sparrow/services/knowoapi/services"
 
-	"github.com/opentracing/opentracing-go"
-
 	jwtmiddleware "github.com/iris-contrib/middleware/jwt"
 	"github.com/kataras/iris/v12"
 )
@@ -54,15 +52,7 @@ func registerRouters(srv *iris.Application, models *model.All, gen *generator.Ke
 	roleService := services.NewRoleService(models)
 	ruleChainService := services.NewRuleChainService(models)
 	subDeviceService := services.NewSubDeviceService(models)
-	v1router := srv.Party("/api/v1", func(ctx iris.Context) {
-		span := opentracing.StartSpan(ctx.Path())
-		defer span.Finish()
-		span.SetTag("http.method", ctx.Method())
-		span.SetTag("http.url", ctx.Path())
-		span.SetTag("http.status_code", ctx.GetStatusCode())
-		ctx.Values().Set("span", span)
-		ctx.Next()
-	})
+	v1router := srv.Party("/api/v1")
 
 	// 登陆,注册
 	loginAPI := mvc.New(v1router.Party("/"))