google app engine - Getting *http.Request from Context on AppEngine -
i'm using app engine, , creating context.context
(golang.org/x/net/context) variable *http.request
.
c := appengine.newcontext(r)
i'm passing context around , i'm trying figure out way *http.request
context.context
in order log http.request
.
i search on doc couldn't find solution.
appengine.newcontext(r)
returns value of type appengine.context
. not same context
type of golang.org/x/net/context
package!
having value of type appengine.context
, can't *http.request
used create it. if need *http.request
, have take care of passing around (you have it, since use create context).
note appengine.context
(which interface type) has method context.request()
, internal use only, not exported call it. , returns interface{}
, not *http.request
. if returns value holding *http.request
, can't rely on method may changed or removed in future versions.
passing *http.request
along appengine.context
is best way. trying context "wizardry" , might break new sdk release. if want simplify it, may create wrapper struct , pass wrapper instead of 2 values, example:
type wrapper struct { c appengine.context r *http.request }
and helper func:
func createctx(r *http.request) wrapper { return wrapper{appengine.newcontext(r), r} }
Comments
Post a Comment