MCPcopy
hub / github.com/gin-gonic/gin / RunFd

Method RunFd

gin.go:607–625  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

605// through the specified file descriptor.
606// Note: this method will block the calling goroutine indefinitely unless an error happens.
607func (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)

Callers 3

TestFileDescriptorFunction · 0.80
TestBadFileDescriptorFunction · 0.80
RunFdFunction · 0.80

Calls 5

RunListenerMethod · 0.95
debugPrintFunction · 0.85
debugPrintErrorFunction · 0.85
CloseMethod · 0.80

Tested by 2

TestFileDescriptorFunction · 0.64
TestBadFileDescriptorFunction · 0.64