37 lines
559 B
Go
37 lines
559 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi"
|
|
"github.com/go-chi/chi/middleware"
|
|
)
|
|
|
|
var (
|
|
conf = newDefaultConfig()
|
|
)
|
|
|
|
func main() {
|
|
|
|
if err := overwriteFromEnv(conf); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
r := chi.NewRouter()
|
|
|
|
r.Use(middleware.Recoverer)
|
|
r.Use(middleware.RequestID)
|
|
r.Use(middleware.RealIP)
|
|
r.Use(middleware.Logger)
|
|
|
|
hostStr := fmt.Sprintf("%s:%s", conf.HTTPHost, conf.HTTPPort)
|
|
log.Printf("listening on http://%s", hostStr)
|
|
|
|
if err := http.ListenAndServe(hostStr, r); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
}
|