package main import ( "fmt" "log" "net/http" "forge.cadoles.com/Pyxis/orion/cmd/server/rpc" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" ) var ( conf = newDefaultConfig() jsonrpc = rpc.NewServer() ) 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) r.Post("/rpc", handleRPC) 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) } } func handleRPC(w http.ResponseWriter, r *http.Request) { jsonrpc.ServeHTTP(w, r) }