Skip to content

Instantly share code, notes, and snippets.

@kirk91
Last active July 16, 2021 14:12
Show Gist options
  • Save kirk91/7569d02256566b0179963a35a63f92eb to your computer and use it in GitHub Desktop.
Save kirk91/7569d02256566b0179963a35a63f92eb to your computer and use it in GitHub Desktop.
Http over unix domain socket
package main
import (
"fmt"
"net"
"net/http"
"os"
)
func main() {
udsPath := "/tmp/http-unix.sock"
os.Remove(udsPath) //nolint:errcheck
lis, err := net.Listen("unix", udsPath)
if err != nil {
panic(err)
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, world!")
})
http.Serve(lis, nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment