Change Formatters to Handlers?

17 views
Skip to first unread message

matryer

unread,
Oct 21, 2011, 10:06:46 AM10/21/11
to goweb
Should we change Formatters so that instead of returning the output,
it writes it? Since it's writing headers too.

We could rename them to Handlers - which might fit in nicer with other
paradigms.

An interface might look like:

type Handler interface {

// handle it
Handle(*Context) os.Error

// Should this handler be used for the specified context?
UseForContext(*Context) bool

}

I wonder also about how we are passing the 'object' to be handled...
perhaps we could set this as a common 'Data' property on the context.

i.e.

context.Data = myObject
handler := GetHandlerForContext(context)
handler.Handle(context)

Mat
Reply all
Reply to author
Forward
0 new messages