Re: [google-appengine-go] Constructors in appengine using Go

47 views
Skip to first unread message

Matt Jibson

unread,
May 9, 2013, 2:28:44 PM5/9/13
to mispl...@gmail.com, google-ap...@googlegroups.com
Yes. Appstats does this (see: https://github.com/mjibson/appstats/blob/master/appstats.go#L221 and the ServeHTTP function below). You would have to wrap your handler1 in something like: http.Handle("/user", UserHandler(handler1)), and define UserHandler as something similar to the linked appstats code.


On Thu, May 9, 2013 at 10:48 AM, <mispl...@gmail.com> wrote:
I know that reason I can't figure this out is because I got frustrated and I'm probably overlooking something incredibly simple somewhere.  But, I need help. 

Suppose I have the following init function.

func init() {
    http.HandleFunc("/user", handler1)
    http.HandleFunc("/user/profile", handler2)
    http.HandleFunc("/user/post", handler3)
     ...
     ...
     ...
}

Every one of these deals with the currently logged in user's profile, so that data needs to be gathered for every one of them. 
Is there any way to fill in a structure for every request without calling a construct method to every single handler?

Any help is greatly appreciated.


--
You received this message because you are subscribed to the Google Groups "google-appengine-go" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengin...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages