Private
Public Access
1
0
Files
Kordophone/main.go

47 lines
1004 B
Go
Raw Normal View History

package main
import (
2023-06-22 11:03:00 -07:00
"os"
"flag"
"net/http"
2023-06-22 11:03:00 -07:00
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"code.severnaya.net/kordophone-mock/v2/web"
)
func main() {
2023-06-22 11:03:00 -07:00
debug := flag.Bool("debug", false, "enable debug logging")
flag.Parse()
// Pretty logging
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
// Default level for this example is info, unless debug flag is present
zerolog.SetGlobalLevel(zerolog.InfoLevel)
if *debug {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
log.Info().Msg("Initializing")
c := web.MockHTTPServerConfiguration{
AuthEnabled: false,
}
2023-06-22 11:03:00 -07:00
addr := ":5738"
s := web.NewMockHTTPServer(c)
httpServer := &http.Server{
2023-06-22 11:03:00 -07:00
Addr: addr,
Handler: s,
}
// Populate with test data
s.Server.PopulateWithTestData()
2023-06-22 11:03:00 -07:00
log.Info().Msgf("Generated test data. %d conversations", len(s.Server.Conversations()))
2023-06-22 11:03:00 -07:00
log.Info().Msgf("Listening on %s", addr)
log.Fatal().Err(httpServer.ListenAndServe())
}