首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有go-swagger响应头的GoLang

带有go-swagger响应头的GoLang
EN

Stack Overflow用户
提问于 2018-07-14 05:01:14
回答 0查看 1.3K关注 0票数 1

我对golang非常陌生,正在尝试设置我的响应头。我有两个标头要设置。我想我误解了一些基本的东西。我也在使用go-swagger来生成我的端点。

我的问题是,我似乎只能设置我的两个头中的一个。Swagger在返回时提供了一个函数"auth.NewAuthLoginUserOK().WithProfileHeader("pickles)“(在"if success”块中)。我如何设置两个header参数?

代码语言:javascript
复制
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()
}

提前谢谢你。

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51332756

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档