Interceptors

37 views
Skip to first unread message

Artem Redkin

unread,
Nov 27, 2012, 7:13:07 AM11/27/12
to golang...@googlegroups.com
Hi.

Are there any plans on adding some kind of interceptor functionality? It would be quite useful to add, for example, authenticationIterceptor, which would get called before dispatching request to controller and set user account data to context.
Maybe I can help implement it (though I'm only starting to use go)?

Thanks.

schultzter

unread,
Mar 11, 2013, 4:50:43 PM3/11/13
to golang...@googlegroups.com
Yeah, sign me up for this one!

I've been trying to build web app with a GAE backend and I found myself adding the same three lines to every handler (get the context,  get the user of the context, check if the user is nil). 

goweb looks perfect in every other aspect, handling all the RESTful stuff. But I'm still trying to figure out how to handle authentication and redirecting/responding to requests when the user isn't logged in. 

I thought using GAE's built-in user package would make things easier for me, and it does but there's still a lot of work to do. Having an interceptor would take care of most of that remaining work.

Thanks,

schultzter

unread,
Mar 11, 2013, 5:36:31 PM3/11/13
to golang...@googlegroups.com
I re-read the wiki, and thought maybe a match-handler could solve this question. But they can't be used with MapRest. I don't know Go well enough to know whether it could easily be added, but I'm tempted to try (though I'd be so far off on a tangent from my original project).

schultzter

unread,
Mar 12, 2013, 12:36:39 PM3/12/13
to golang...@googlegroups.com
Hmm, I did some work on this last night, and having using a match function wouldn't solve the problem since I still need to provide an appropriate response to the request, especially for an API.


On Monday, March 11, 2013 4:50:43 PM UTC-4, schultzter wrote:

matryer

unread,
May 28, 2013, 11:53:27 PM5/28/13
to golang...@googlegroups.com, er...@schultzter.ca
Guys,

The new handlers model is perfect for what you need.  It was designed after we read this thread.


Just write your own class that implements goweb.handlers.Handler and add it using the goweb.MapBefore(yourHandler).  Feedback very welcome.

Regards,
Mat

matryer

unread,
May 28, 2013, 11:53:40 PM5/28/13
to golang...@googlegroups.com
Guys,

The new handlers model is perfect for what you need.  It was designed after we read this thread.


Just write your own class that implements goweb.handlers.Handler and add it using the goweb.MapBefore(yourHandler).  Feedback very welcome.

Regards,
Mat

Reply all
Reply to author
Forward
0 new messages