Skip to content
serve.Serve()
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
LICENSE
README.md
go.mod
go.sum
recover.go
serve.go

README.md

servers-gonna-serve docs

A small package that wraps up serving a http.Handler via a port or socket. It catches interrupts so any defers will run properly.

package main

import (
  "hawx.me/code/serve"
  "net/http"
  "flag"
)

var (
  port   = flag.String("port", "8080", "")
  socket = flag.String("socket", "", "")
)

func main() {
  flag.Parse()

  http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    // ...
  })

  serve.Serve(*port, *socket, http.DefaultServeMux)
}
You can’t perform that action at this time.