github packages -> in the meantime, need to keep all files in same package.

This commit is contained in:
Josh Ashton
2024-08-05 17:34:57 -06:00
parent 3e94d5c8ba
commit 68127cdb2c
6 changed files with 26 additions and 376 deletions
@@ -1,31 +0,0 @@
package main
import (
"github.com/gorilla/mux"
"log"
"net/http"
"time"
)
// Serve a directory to a port.
func servePage(router *mux.Router, dest string, path string, port int) {
router.PathPrefix(path).Handler(http.FileServer(http.Dir(dest)))
srv := &http.Server{
Addr: "0.0.0.0: " + string(port),
// Good practice to set timeouts to avoid Slowloris attacks.
WriteTimeout: time.Second * 15,
ReadTimeout: time.Second * 15,
IdleTimeout: time.Second * 60,
Handler: router, // Pass our instance of gorilla/mux in.
}
// Run our server in a goroutine so that it doesn't block.
go func() {
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
log.Println(err)
}
}()
log.Println("Web server is running on port " + string(port))
}