Gin: Different Context? (Appengine)

Created on 15 Aug 2014  路  1Comment  路  Source: gin-gonic/gin

Is it possible to have a different Context then gin.Context? I'am using appengine and i need to use some app engine related context

https://developers.google.com/appengine/docs/go/gettingstarted/usingusers

Most helpful comment

hey, you can't. but you do not need to. Since the app engine context is a different matter.

As you can see in the sample code:

func handler(w http.ResponseWriter, r *http.Request) {
    appengineContext := appengine.NewContext(r)

the app engine context takes as argument the http.Request, right?

You can do exactly the same in Gin, since the Gin context includes the SAME http.Request.
Try this:

func handler(c *gin.Context) {
    appengineContext := appengine.NewContext(c.Request)

does it make sense?

>All comments

hey, you can't. but you do not need to. Since the app engine context is a different matter.

As you can see in the sample code:

func handler(w http.ResponseWriter, r *http.Request) {
    appengineContext := appengine.NewContext(r)

the app engine context takes as argument the http.Request, right?

You can do exactly the same in Gin, since the Gin context includes the SAME http.Request.
Try this:

func handler(c *gin.Context) {
    appengineContext := appengine.NewContext(c.Request)

does it make sense?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ccaza picture ccaza  路  3Comments

ghost picture ghost  路  3Comments

cxk280 picture cxk280  路  3Comments

nxvl picture nxvl  路  3Comments

olegsobchuk picture olegsobchuk  路  3Comments