ghttp_server_util.go 702 B

1234567891011121314151617181920212223
  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/gogf/gf.
  6. package ghttp
  7. import "net/http"
  8. // WrapF is a helper function for wrapping http.HandlerFunc and returns a ghttp.HandlerFunc.
  9. func WrapF(f http.HandlerFunc) HandlerFunc {
  10. return func(r *Request) {
  11. f(r.Response.Writer, r.Request)
  12. }
  13. }
  14. // WrapH is a helper function for wrapping http.Handler and returns a ghttp.HandlerFunc.
  15. func WrapH(h http.Handler) HandlerFunc {
  16. return func(r *Request) {
  17. h.ServeHTTP(r.Response.Writer, r.Request)
  18. }
  19. }