package server

import (
	"net/http"
	"github.com/fiskerinc/cloud-services/services/optimus/handlers"

	h "github.com/fiskerinc/cloud-services/pkg/httphandlers"
	"github.com/fiskerinc/cloud-services/pkg/logger"
	"github.com/julienschmidt/httprouter"
)

const port string = ":8077"

func StartHTTPServer() {
	router := httprouter.New()
	router.PanicHandler = h.HttpRouterPanicHandler
	addHandler(router, http.MethodGet, "/reset", handlers.ResetFilters)
	logger.Fatal().AnErr("http.ListenAndServe", http.ListenAndServe(port, router)).Send()
}

func addHandler(router *httprouter.Router, method string, path string, handler http.HandlerFunc) {
	router.HandlerFunc(method, h.HttpRouterHandleBaseURL(path), handler)
}
