spiegel/internal/router/init.go
Ada 5b67a66d74
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/lint Pipeline was successful
Support clone of archived repo via /git/<name>
2024-05-26 22:00:55 +02:00

29 lines
532 B
Go

package router
import (
"net/http"
"git.gnous.eu/ada/spiegel/internal/constant"
"github.com/sirupsen/logrus"
)
type Config struct {
Listen string
Archive string
}
func (c Config) Router() {
mux := http.NewServeMux()
fs := http.FileServer(http.Dir(c.Archive))
mux.Handle("/git/", http.StripPrefix("/git/", fs))
server := &http.Server{
Addr: c.Listen,
Handler: mux,
ReadHeaderTimeout: constant.HTTPTimeout,
}
logrus.Info("HTTP listen on :5000")
logrus.Fatal(server.ListenAndServe())
}