美文网首页
gin web framework 2022-04-15

gin web framework 2022-04-15

作者: 9_SooHyun | 来源:发表于2022-04-15 20:57 被阅读0次

    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.

    相关文章

      网友评论

          本文标题:gin web framework 2022-04-15

          本文链接:https://www.haomeiwen.com/subject/rvjqertx.html