The module was code.aneur.in/cloud/ultrashorty but go.mod (and main.go's internal import) still said gogs.home.aneur.in/go/ultrashorty, a host that no longer exists. Self-consistent so it built, but wrong for anyone fetching it and confusing to read. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
37 lines
750 B
Go
37 lines
750 B
Go
package main
|
|
|
|
import (
|
|
"net"
|
|
"net/http"
|
|
|
|
"github.com/alecthomas/kong"
|
|
"github.com/rs/zerolog"
|
|
"code.aneur.in/cloud/ultrashorty/internal"
|
|
)
|
|
|
|
func main() {
|
|
cli := &internal.CLI{}
|
|
kong.Parse(cli, kong.Name("ultrashorty"), kong.Description("Really simple HTTP redirection using a CSV file."))
|
|
|
|
redirects, err := internal.ReadCsvRedirects(cli.File)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
srv := &internal.HttpServer{
|
|
CLI: cli,
|
|
Log: zerolog.New(zerolog.NewConsoleWriter()).With().Timestamp().Logger(),
|
|
Redirects: redirects,
|
|
}
|
|
|
|
addr := net.JoinHostPort(cli.Host, cli.Port)
|
|
errc := make(chan error)
|
|
go func() {
|
|
errc <- http.ListenAndServe(addr, srv)
|
|
}()
|
|
|
|
srv.Log.Info().Msgf("Listening at %s", addr)
|
|
err = <-errc
|
|
panic(err)
|
|
}
|