You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When looking at apex/log's code (which use a net/http like handler style instead of logrus like formatter writer style), found the handy util type HandlerFunc func... which also appears in net/http
typeHandlerinterface {
ServeHTTP(ResponseWriter, *Request)
}
// The HandlerFunc type is an adapter to allow the use of// ordinary functions as HTTP handlers. If f is a function// with the appropriate signature, HandlerFunc(f) is a// Handler that calls f.typeHandlerFuncfunc(ResponseWriter, *Request)
// ServeHTTP calls f(w, r).func (fHandlerFunc) ServeHTTP(wResponseWriter, r*Request) {
f(w, r)
}
The question is, why use func (f HandlerFunc) instead of func (f *HandlerFunc)
The text was updated successfully, but these errors were encountered:
- it use lock in handler implementations, for logging to stdout/err, I
think the reason the lock is needed is they call fmt.Fprintf
multiple times (for the message and fields) for a single log entry
- the overall process is entry.Debug -> Logger.log ->
Handler.HandleLog(*Entry) -> write to ouput (i.e.
fmt.Fprintf(io.Writer))
- it's good they didn't put Output inside logger, als othe HandlerFunc
part like `net/http`, though I still didn't know why it's using value
instead of pointer receiver #30
- change test in makefile to only test new packages
- add ErrorHandlerFunc like net/http dyweb/gommon#30
- won't even realize that without adding unit test
Arise from #26
When looking at apex/log's code (which use a net/http like handler style instead of logrus like formatter writer style), found the handy util
type HandlerFunc func...
which also appears innet/http
https://golang.org/src/net/http/server.go#L1914
The question is, why use
func (f HandlerFunc)
instead offunc (f *HandlerFunc)
The text was updated successfully, but these errors were encountered: