草庐IT

gorilla-toolkit

全部标签

javascript - gorilla /csrf 的问题

所以,对于我的生活,我无法弄清楚如何在不直接将gorilla的csrf注入(inject)字段时让它工作。它一直在谈论通过header和cookie传递它,但我所做的一切似乎都不起作用......这是我的go服务器所拥有的:`packagemainimport("gorilla/mux""gorilla/csrf""net/http""log""encoding/json""http/template""time")funcshowLoginPage(whttp.ResponseWriter,r*http.Request){w.Header().Set("Set-Cookie","_g

go - gin-gonic 和 gorilla/websocket 不传播消息

所以我对这个例子做了一些修改,让它可以和gin-gonic一起工作https://github.com/utiq/go-in-5-minutes/tree/master/episode4多个客户端之间的websocket握手成功。问题在于,当客户端发送消息时,消息不会传播到其余客户端。 最佳答案 我看过你的commitchanges第4集。我的观察如下:您正在为streamhandler的每个传入请求创建hub实例.hub实例用于跟踪连接等,因此您在每次请求时都会丢失它。您已经删除了index/home处理程序(可能您想转换为gin

go - 使用 Gorilla MUX 和 Negroni 的子路由中间件

我试图只在某些路由上添加中间件。我写了这段代码:funcmain(){router:=mux.NewRouter().StrictSlash(false)admin_subrouter:=router.PathPrefix("/admin").Subrouter()//handlers.CombinedLoggingHandlercomesfromgorilla/handlersrouter.PathPrefix("/admin").Handler(negroni.New(negroni.Wrap(handlers.CombinedLoggingHandler(os.Stdout,ad

Golang Gorilla CEX.IO Websocket 认证错误

我目前正在尝试连接到CEX.IO比特币交易所的websocket。Websocket连接正常,但在身份验证时出现错误:Timestampisnotin20secrange。我不知道这是什么错误。createSignature的测试用例1和2正常(https://cex.io/websocket-api#authentication)。认证代码:functoHmac256(messagestring,secretstring)string{key:=[]byte(secret)h:=hmac.New(sha256.New,key)h.Write([]byte(message))retur

go - Gorilla mux 路由器不提供静态内容——比如 style.css、script.js

我是Go语言的初学者。我试图用GorrilaMux路由器提供静态容器。但是css和js不是我的服务器。projectf-mymux.god-pagesf-home.htmlf-about.htmld-publicd-cssf-style.cssd-jsf-script.js注意:f-文件&d-目录我的GO代码如下:packagemainimport("bufio""github.com/gorilla/mux""log""net/http""os""strings""text/template")funcmain(){serverWeb()}varstaticPages=populat

go - 如何在 gorilla/mux 包中初始化 HandleFunc 中的变量

我有一个处理函数:r.HandleFunc("/getstatus_a/{price}",getStatusWithPrice).Methods("GET")price是int变量,我需要在路径中初始化它。我该怎么做?附言在getStatusWithPrice()price中用作在sql请求中传输的参数。 最佳答案 问题解决了vars:=mux.Vars(r)price:=vars["price"] 关于go-如何在gorilla/mux包中初始化HandleFunc中的变量,我们在St

rest - golang gorilla/mux 和 rest GET 问题

我的删除处理程序:(我正在使用“github.com/gorilla/mux”)funcDeletePerson(whttp.ResponseWriter,r*http.Request){params:=mux.Vars(r)item:=params["id"]fmt.Println("Item=",item)...当被以下curl命令调用时返回Item="2":curl-XDELETEhttp://localhost:8000/address/2但是,我的测试代码:funcTestDeletePerson(t*testing.T){person:=&Person{UniqID:"2"

gorilla /websocket 设置读取限制?

//SetReadLimitsetsthemaximumsizeforamessagereadfromthepeer.Ifa//messageexceedsthelimit,theconnectionsendsaclosemessagetothepeer//andreturnsErrReadLimittotheapplication.func(c*Conn)SetReadLimit(limitint64){c.readLimit=limit}极限的单位是什么?知识库?MB? 最佳答案 基于gorilla/websocket的来源,以

go - 无法使用 Golang 从带有 mySQL 后端的 gorilla / session 中获取值(value)

我试图在使用mySQL后端的gorillasession中为我的模型保存一个结构,但当我尝试检索它时,venueID只得到0。我可以毫不费力地保存和获取即显消息。我的目标是在session中保存模型结构并检索它以获取编辑、更新和删除功能中的ID号。这是我的代码:typeappResourcestruct{tmpl*template.Template//net/httpstore*mysqlstore.MySQLStoredb*sql.DB//database/sql}//newAppResourcefunctiontopassglobalvarfuncnewAppResource(st

go - 如何使用 Gorilla 指定 WS ping 的频率

WebSocketRFC指出有用于ping/pong的控制帧。为了避免将应用程序代码编写为保活机制,是否可以使用GorillaWebSockets指定ping的频率? 最佳答案 因为应用程序负责使用GorillaWebSocket包发送ping,所以应用程序可以完全控制发送ping的频率。参见chatexample有关如何发送ping并使用它们检测死连接或卡住连接的示例。 关于go-如何使用Gorilla指定WSping的频率,我们在StackOverflow上找到一个类似的问题: