RunFd attaches the router to a http.Server and starts listening and serving HTTP requests through the specified file descriptor. Note: this method will block the calling goroutine indefinitely unless an error happens.
(fd int)
| 605 | // through the specified file descriptor. |
| 606 | // Note: this method will block the calling goroutine indefinitely unless an error happens. |
| 607 | func (engine *Engine) RunFd(fd int) (err error) { |
| 608 | debugPrint("Listening and serving HTTP on fd@%d", fd) |
| 609 | defer func() { debugPrintError(err) }() |
| 610 | |
| 611 | if engine.isUnsafeTrustedProxies() { |
| 612 | debugPrint("[WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.\n" + |
| 613 | "Please check https://github.com/gin-gonic/gin/blob/master/docs/doc.md#dont-trust-all-proxies for details.") |
| 614 | } |
| 615 | |
| 616 | f := os.NewFile(uintptr(fd), fmt.Sprintf("fd@%d", fd)) |
| 617 | defer f.Close() |
| 618 | listener, err := net.FileListener(f) |
| 619 | if err != nil { |
| 620 | return |
| 621 | } |
| 622 | defer listener.Close() |
| 623 | err = engine.RunListener(listener) |
| 624 | return |
| 625 | } |
| 626 | |
| 627 | // RunQUIC attaches the router to a http.Server and starts listening and serving QUIC requests. |
| 628 | // It is a shortcut for http3.ListenAndServeQUIC(addr, certFile, keyFile, router) |