added refresh db capability and did some refactoring
This commit is contained in:
@@ -7,20 +7,25 @@ import (
|
||||
"gitea.ewpt3ch.dev/ewpt3ch/pkgstash/internal/cache"
|
||||
)
|
||||
|
||||
const repoRoot = "/home/ewpt3ch/dev/pacman-cache-server/tmprepo"
|
||||
type Server struct {
|
||||
cfg *Config
|
||||
c *cache.Cache
|
||||
}
|
||||
|
||||
func main() {
|
||||
const port = "8090"
|
||||
cfg := NewConfig()
|
||||
c := cache.NewCache(cfg.RepoPath, cfg.MirrorURL)
|
||||
c := cache.NewCache(cfg.MirrorRoot, cfg.MirrorURL)
|
||||
srv := &Server{cfg: cfg, c: c}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("GET /{repo}/os/{arch}/{file}", func(w http.ResponseWriter, req *http.Request) {
|
||||
handlePackage(w, req, c)
|
||||
})
|
||||
mux.HandleFunc("GET /{repo}/os/{arch}/{file}", srv.handlePackage)
|
||||
|
||||
if err := srv.c.Refresh(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
httpServe := &http.Server{
|
||||
Addr: ":" + port,
|
||||
Addr: ":" + srv.cfg.Port,
|
||||
Handler: mux,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user