我对 golang 很陌生,并试图设置我的响应标头。我有两个要设置的标题。我认为我误解了一些基本的东西。我也在使用 go-swagger 来生成我的端点。
我的问题是我似乎只能设置我的两个标题之一。Swagger 在返回时提供了一个函数“auth.NewAuthLoginUserOK().WithProfileHeader(“pickles)”(在“如果成功”块中)。如何设置两个标头参数?
func AuthLoginRouteHandler(params auth.AuthLoginUserParams) middleware.Responder {
transactionId := redFalconLogger.GetTransactionId()
redFalconLogger.LogDebug("AuthLoginRouteHandler", transactionId)
email := params.Body.Email
password := params.Body.Password
//Check to ensure that they are not nil
if email == "" || password == ""{
redFalconLogger.LogError("Got an empty string on a username/password", transactionId)
return auth.NewAuthLoginUserBadRequest()
}
//use pointers to limit in flight private data
pointerEmail := &email
pointerPassword := &password
//Call the auth domain
success := authDomain.LoginUser(pointerEmail,pointerPassword,transactionId)
if success {
return auth.NewAuthLoginUserOK().WithProfileKeyHeader("pickles")
}
redFalconLogger.LogDebug("Failed Login: ", transactionId)
return auth.NewAuthLoginUserBadRequest()
}
先感谢您。