コード例 #1
0
func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	l4g.Debug("%v", r.URL.Path)

	c := &Controller{
		RequestId: model.NewId(),
		IpAddress: GetIpAddress(r),
		Protocol:  GetProtocol(r),
	}

	w.Header().Set("X-Request-ID", c.RequestId)
	w.Header().Set("Content-Type", "application/json")

	if c.Err == nil {
		h.handleFunc(c, w, r)
	}

	if c.Err != nil {
		c.Err.RequestId = c.RequestId
		c.LogError(c.Err)
		c.Err.Where = r.URL.Path

		w.WriteHeader(c.Err.StatusCode)
		w.Write([]byte(c.Err.ToJson()))
	}
}
コード例 #2
0
func main() {
	// Load the configuration (isn't this easy?)
	l4g.LoadConfiguration("example.xml")

	// And now we're ready!
	l4g.Finest("This will only go to those of you really cool UDP kids!  If you change enabled=true.")
	l4g.Debug("Oh no!  %d + %d = %d!", 2, 2, 2+2)
	l4g.Info("About that time, eh chaps?")
}
コード例 #3
0
func InitCategory() {
	l4g.Debug("Initializing categories api routes")

	for _, route := range routes {
		Srv.Router.
			Methods(route.Method).
			Path(route.Path).
			Name(route.Name).
			Handler(route.HandlerFunc)
	}
}