gin web framework 2022-04-15

2022-04-15  本文已影响0人  9_SooHyun

Gin

Gin uses a custom version of HttpRouter as muxer
Gin uses encoding/json as default json package but you can change it by build from other tags.
Engine is the gin framework's instance, it contains the muxer, middleware and configuration settings.

gin如何处理请求

one service goroutine accepts requests and creating a new service goroutine for each

gin实际上还是用了 http.ListenAndServe(addr string, handler Handler) error监听 TCP 端口并提供路由服务
func http.ListenAndServe(addr string, handler Handler) error
->func (srv *Server) ListenAndServe() error
->func (srv *Server) Serve(l net.Listener) error

// Serve accepts incoming connections on the Listener l, creating a
// new service goroutine for each. The service goroutines read requests and
// then call srv.Handler to reply to them.
//
// HTTP/2 support is only enabled if the Listener returns *tls.Conn
// connections and they were configured with "h2" in the TLS
// Config.NextProtos.
//
// Serve always returns a non-nil error and closes l.
// After Shutdown or Close, the returned error is ErrServerClosed.

上一篇下一篇

猜你喜欢

热点阅读