26 lines
509 B
Go
26 lines
509 B
Go
package api
|
|
|
|
import (
|
|
"fmt"
|
|
"log/slog"
|
|
"net/http"
|
|
"time"
|
|
|
|
"git.schreifuchs.ch/lou-taylor/accounting/internal/config"
|
|
)
|
|
|
|
func Start(log *slog.Logger, address string, cfg *config.Config) error {
|
|
mux := http.NewServeMux()
|
|
RegisterRoutes(log, mux, cfg)
|
|
|
|
s := &http.Server{
|
|
Addr: address,
|
|
Handler: mux,
|
|
ReadTimeout: 10 * time.Second,
|
|
WriteTimeout: 10 * time.Second,
|
|
MaxHeaderBytes: 1 << 20,
|
|
}
|
|
log.Info(fmt.Sprintf("Start API on %s", address))
|
|
return s.ListenAndServe()
|
|
}
|