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

Method RunUnix

gin.go:581–602  ·  view source on GitHub ↗

RunUnix attaches the router to a http.Server and starts listening and serving HTTP requests through the specified unix socket (i.e. a file). Note: this method will block the calling goroutine indefinitely unless an error happens.

(file string)

Source from the content-addressed store, hash-verified

579// through the specified unix socket (i.e. a file).
580// Note: this method will block the calling goroutine indefinitely unless an error happens.
581func (engine *Engine) RunUnix(file string) (err error) {
582 debugPrint("Listening and serving HTTP on unix:/%s", file)
583 defer func() { debugPrintError(err) }()
584
585 if engine.isUnsafeTrustedProxies() {
586 debugPrint("[WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.\n" +
587 "Please check https://github.com/gin-gonic/gin/blob/master/docs/doc.md#dont-trust-all-proxies for details.")
588 }
589
590 listener, err := net.Listen("unix", file)
591 if err != nil {
592 return
593 }
594 defer listener.Close()
595 defer os.Remove(file)
596
597 server := &http.Server{ // #nosec G112
598 Handler: engine.Handler(),
599 }
600 err = server.Serve(listener)
601 return
602}
603
604// RunFd attaches the router to a http.Server and starts listening and serving HTTP requests
605// through the specified file descriptor.

Callers 3

TestUnixSocketFunction · 0.80
TestBadUnixSocketFunction · 0.80
RunUnixFunction · 0.80

Calls 5

HandlerMethod · 0.95
debugPrintFunction · 0.85
debugPrintErrorFunction · 0.85
CloseMethod · 0.80

Tested by 2

TestUnixSocketFunction · 0.64
TestBadUnixSocketFunction · 0.64