草庐IT

missing-cookies

全部标签

go - Cookie 不使用 Golang 设置

我有一个用于登录用户的RESTAPI,它在浏览器上为登录用户设置一个cookie,并且运行良好。问题是当用户从注册API完成注册时我想调用登录​​API,这样每件事都运行良好但cookie未设置为浏览器。这是登录API:varloginViaDjangoApiShim=http.HandlerFunc(func(whttp.ResponseWriter,r*http.Request){vartloginPostvaroldCookieTokenstringdecoder:=json.NewDecoder(r.Body)_:=decoder.Decode(&t)expiration:=t

unit-testing - 如何修复测试用例中的 "missing type in composite literal"

我正在尝试为函数ReadField()编写测试代码,但我在定义测试用例时遇到了困难。它给出了一个错误“复合文字中缺少类型”。我相信这只是一些语法错误。我已经尝试在函数体之外定义结构体,但它仍然会给出相同的错误。ReadField(string,string,bool)(bool,string)funcTestReadField(t*testing.T){testCases:=[]struct{NamestringInputstruct{FirstStringstringSecondStringstringSomeBoolbool}Expectedstruct{IsValidboolMe

go - 如何读取cookie?

我通过javascript设置了一个cookie,例如:setCookie("appointment",JSON.stringify({appointmentDate:selectedDay.date,appointmentStartMn:appointment.mnRange[0],appointmentId:appointment.id||0,appointmentUserId:appointment.user.id||0}));设置cookie后,我想将用户重定向到预订页面:window.location.href="https://localhost:8080/booking/

go - "Missing type in composite literal"结构中映射的匿名列表

编辑:编译错误在Missingtypeincompositeliteral与我的问题相同,它们的组成差异很大,以至于我不明白我将如何将解决方案应用到我的程序中,因此创建了这个问题。我是新来的,我正在尝试为我已验证可以成功调用的函数编写测试,如下所示:funcmain(){items:=[]map[string]int{map[string]int{"value":100,"weight":5,},map[string]int{"value":90,"weight":2,},map[string]int{"value":80,"weight":2,},}fmt.Println(KnapS

go - 设置 cookie 不被检测

我在尝试检索已设置的cookie时遇到问题,如果未设置,我想更新它然后检索它。首先,我有一个设置cookie的函数:funcIndexHandler(whttp.ResponseWriter,r*http.Request){...ck:=http.Cookie{Name:"id",Value:5,MaxAge:60,}}然后在另一个函数中我检查该cookie是否存在,如果它(抛出错误)然后我重新创建它funcCheckUpdateCookie(whttp.ResponseWriter,r*http.Request){val,err:=r.Cookie("id")iferr!=nil{c

bash - Golang OpenGL 错误 PlatformError : X11: The DISPLAY environment variable is missing panic: NotInitialized: The GLFW library is not initialized

我似乎无法让opengl与golang一起工作。我想尝试golang,但设置起来非常痛苦,现在我无法得到我从thiswebsite复制粘贴的东西.这是我使用的代码:(fromthewebsite).我在运行它之前执行了这两个命令(在Windows上使用wsl):gogetgithub.com/go-gl/gl/v4.1-core/glgogetgithub.com/go-gl/glfw/v3.2/glfw这是我得到的完整错误:2018/11/2113:43:33PlatformError:X11:TheDISPLAYenvironmentvariableismissingpanic:N

google-app-engine - CookieJar 不捕获传入的 cookie

我正在尝试让Go在网页上为我提交一个表单来模拟登录。从那里我尝试使用cookie来保持持久session,以便再次调用子页面。我能够毫无问题地成功登录,我只是在捕获返回服务器设置的cookie时遇到了问题。我想知道是不是因为他们的登录脚本做了几次重定向?(我得到一个输出)。为什么我没有捕捉到返回的cookie有什么想法吗?这是我使用的代码:import("crypto/tls""fmt""io/ioutil""net/http""net/url""strings""sync")typeJarstruct{lksync.Mutexcookiesmap[string][]*http.Coo

mongodb - 如何将 BSON _Id 分配给 cookie(Go,Mongodb)

我正在尝试创建一个gocookie。我想从Mongodb分配Id以存储在Cookie中。但是在编译时出现如下错误:-“结构文字中的未知http.Cookie字段‘Id’”以下是我的代码:-getUser:=user.CheckDB()expiration:=time.Now().Add(365*24*time.Hour)//TheErrorisCausedbytheNextLinecookie:=http.Cookie{Id:getUser[0].Id,Name:getUser[0].Email,Value:getUser[0].Password,Expires:expiration}

cookies - 使用 Go 客户端接收和发送 cookie?

我希望我的Go应用程序通过网站进行身份验证,然后使用收到的cookie访问安全位置。以下curl示例准确说明了我正在尝试做的事情:通过x-www-form-urlencoded对网站进行身份验证并保存cookie。数据自动进行urlencoded:curl'https://www.example.com/login'\--cookie-jarcookies.txt\--header'Content-Type:application/x-www-form-urlencoded'\--data'user=USERNAME&pass=PASS'现在身份验证cookie保存在cookies.t

Golang gin-gonic 反向代理导致 panic "interface conversion: *http.timeoutWriter is not http.CloseNotifier: missing method CloseNotify"

我正在使用GinGonic创建反向代理端点的框架,目标端点使用grpcGateway提供服务使用下面给出的代码。这类似于为Gin建议的反向代理方法here和hereep1:=v1.Group("/ep1"){ep1.GET("/ep2",reverseProxy("http://localhost:50000"))}funcreverseProxy(targetstring)gin.HandlerFunc{url,err:=url.Parse(target)iferr!=nil{log.Println("ReverseProxytargeturlcouldnotbeparsed:",e