草庐IT

google-http-client

全部标签

google-app-engine - 应用程序.yaml : wildcard in URL with static_dir?

我尝试将正则表达式匹配为app.yaml中的目录名称无效:-url:/v1_.*static_dir:static/v1expiration:"364d"虽然thisofficialspec表示支持正则表达式语法。有什么办法可以做到这一点吗?即/v1_2014-01-29/img/logo.png应该匹配静态文件/static/v1/img/logo.png。琐事我使用GoogleAppEngine为Go提供服务网络应用程序。我想最大限度地延长浏览器缓存的生命周期,最大限度地减少请求数量,并且仍然提供我的css/js/png的新版本,我相信revvingfilenames是实现这一目标

go - 获取 Go 的 HTTP post 来模拟 curl -d

我正在尝试通过Go将内容发布到nginx服务器。我已验证我能够通过curl正确发布此内容,特别是使用此命令:$curlhttp://example.com/myendpoint-d"SomeText"我能够看到这个POST,并正确处理它。但是,当我尝试使用Go执行POST时,它被服务器拒绝了。在nginx访问日志中,我看到这两行:127.0.0.1--[30/Jan/2014:05:57:34+0000]"POST/myendpointHTTP/1.1"4000"-""Go1.1packagehttp"127.0.0.1--[30/Jan/2014:05:57:39+0000]"Som

http - 如何使用 golang 定义自定义 mux

我查看了mux的源代码,但我只想要一些简单的东西,而不是使用所有功能。我想在url中获取“id”的值,如/url/{id},在req.Form中设置值并像mux一样清理路径。像这样的代码r:=http.NewServeMux()r.HandlerFunc("/",func(whttp.ResponseWriter,r*http.Request){//Cleanpathtocanonicalformandredirect.ifp:=cleanPath(req.URL.Path);p!=req.URL.Path{url:=*req.URLurl.Path=pp=url.String()//

google-app-engine - 如何对作为 slice 的接口(interface){}进行子 slice ?

datastore.GetMulti(cappengine.Context,key[]*Key,dstinterface{})API最多允许我获取1000个实体。我想得到更多。一般解决这个问题的一个明显方法是创建一个包装函数mypkg.GetMulti()子slice(key[0:1000],key[1000:2000]...)原始参数并多次调用datastore.GetMulti()。很清楚如何对key[]*Key进行子slice,但是我如何对dstinterface{}进行子slice,它可能是://dstmustbea[]S,[]*S,[]Ior[]P,forsomestruct

google-app-engine - 特定页面的谷歌应用引擎身份验证

我正在尝试在golang平台上使用google-app-engine进行开发,我希望仅在特定页面上执行检查(针对登录用户)。例如:访问“/”路径的用户如果已登录,将被重定向到“/site”,或者将显示有关该产品的页面。当用户访问“/members”、“/users”、“/items”页面时,如果未通过身份验证,将被重定向到登录页面。一个简单的go代码建议:packagehelloimport("fmt""net/http""appengine""appengine/user")funcinit(){http.HandleFunc("/",site)http.HandleFunc("/"

google-app-engine - 祖先查询导致 API 错误 4 (datastore_v3 : NEED_INDEX): no matching index found error

我在处理祖先查询时遇到了很大的困难。这是有效的代码:...uk:=datastore.NewKey(c,config.DatastoreDuelIdKind,did,0,nil)_,err:=datastore.NewQuery(config.DatastoreQuestionInDuelKind).Ancestor(uk).GetAll(c,&roundsPlayedInDuel)...上面的代码产生了正确的结果。现在,如果我在config.DatastoreQuestionInDuelKind的属性上添加Order过滤器,查询将失败并出现NEED_INDEX错误。但是这个失败了:_

google-app-engine - GAE Go - 如何将私有(private)变量放入数据存储区?

我正在编写GoogleAppEngineGolang应用程序。我想要一个带有私有(private)变量的struct,这些变量只能通过适当的函数设置,例如:typeFoostruct{barstring}func(f*Foo)SetBar(bstring){f.bar="BAR:"+b}我希望能够将此数据保存在数据存储区中。但是,数据存储区似乎没有保存私有(private)变量。如何在数据存储中存储私有(private)变量? 最佳答案 如果你的类型实现了PropertyLoadSaverinterface就可以:func(f*Fo

google-app-engine - 在 beegae 中使用 CSS

我正在使用Beegae包和GoogleCloudSDK。我的项目可以运行,但我无法访问我的CSS文件。它位于我项目根目录中的static\css中(我使用Windows)。我试过SetStaticPath,设置DirectoryIndex为true,直接设置静态路径。我的html是我不断得到INFO2014-07-2907:16:47,546module.py:640]默认值:“GET/static/css/style.cssHTTP/1.1”4042010目前我的路由器代码是packageroutersimport("beegoapp2/controllers""github.com

oauth - 如何使用 Google API 交换 OAUTH token ( Go )

这是我到目前为止返回“400错误”的结果。难道我做错了什么?我无法弄清楚为什么不起作用,因为请求非常简单packagemainimport("code.google.com/p/goauth2/oauth""fmt""log")funcmain(){cachefile:="cache.json"code:="4/xxxxx.8uFT5Z0slpMbJvIeHux6iLY_9k7ajw"//thecodereceivedfromtheURLredirect//Setupaconfiguration.config:=&oauth.Config{ClientId:"xx.apps.googl

xml - Golang net/http 包调用后返回base64

下面的调用以某种方式返回base64字符串而不是xml输出。我需要对此进行解码才能看到xml。//POSTfunc(u*UserResource)authenticateUser(request*restful.Request,response*restful.Response){Api:=new(Api)Api.url="http://api.com"usr:=new(User)err:=request.ReadEntity(usr)iferr!=nil{response.AddHeader("Content-Type","application/json")response.Wri