package api

import (
	"fmt"
	"log"
	"net/http"
)

type router struct {
	addr      string
	hrequests []handleRequest
}

type handleRequest struct {
	path    string
	handler func(http.ResponseWriter, *http.Request)
}

func Launcher(port int) {
	router := router{
		addr: fmt.Sprint(":", port),
		hrequests: []handleRequest{
			{"/", homePage},
			{"/insert", insert},
		},
	}
	for _, hrequest := range router.hrequests {
		http.HandleFunc(hrequest.path, hrequest.handler)
	}
	log.Fatal(http.ListenAndServe(router.addr, nil))
}
