github.com/wangyougui/gf/v2@v2.6.5/net/ghttp/ghttp_server_util.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/wangyougui/gf.
     6  
     7  package ghttp
     8  
     9  import "net/http"
    10  
    11  // WrapF is a helper function for wrapping http.HandlerFunc and returns a ghttp.HandlerFunc.
    12  func WrapF(f http.HandlerFunc) HandlerFunc {
    13  	return func(r *Request) {
    14  		f(r.Response.Writer, r.Request)
    15  	}
    16  }
    17  
    18  // WrapH is a helper function for wrapping http.Handler and returns a ghttp.HandlerFunc.
    19  func WrapH(h http.Handler) HandlerFunc {
    20  	return func(r *Request) {
    21  		h.ServeHTTP(r.Response.Writer, r.Request)
    22  	}
    23  }