You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

41 lines
926 B

// Command webfilebrowser starts the HTTP server for the file browser.
package main
import (
"errors"
"log/slog"
"net/http"
"os"
"webfilebrowser/internal/config"
)
const defaultAddress = ":8080"
func main() {
logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
applicationConfig, err := config.Load()
if err != nil {
logger.Error("load root configuration", "error", err)
os.Exit(1)
}
for _, root := range applicationConfig.Roots {
logger.Info("configured browse root", "name", root.Name, "path", root.Path)
}
address := os.Getenv("WEB_FILE_BROWSER_ADDR")
if address == "" {
address = defaultAddress
}
server := &http.Server{
Addr: address,
Handler: http.NewServeMux(),
}
logger.Info("starting web file browser", "address", address)
if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.Error("serve HTTP", "error", err)
os.Exit(1)
}
}