package main import ( "log" "net/http" "os" "path/filepath" "opds-explorer/internal/handlers" "opds-explorer/internal/proxy" ) func main() { proxyClient := proxy.NewClient() h := handlers.New(proxyClient) mux := http.NewServeMux() // API: fetch OPDS feed (proxies request, returns parsed + raw) mux.HandleFunc("GET /api/fetch", h.FetchFeed) mux.HandleFunc("POST /api/fetch", h.FetchFeed) // API: stream a URL through the server (e.g. for images to avoid CORS) mux.HandleFunc("GET /api/proxy", h.ProxyResource) // Serve Vue SPA from dist (or embedded) dist := os.Getenv("OPDS_DIST") if dist == "" { dist = filepath.Join(".", "dist") } if info, err := os.Stat(dist); err == nil && info.IsDir() { mux.Handle("/", http.FileServer(http.Dir(dist))) } else { // Dev: serve a simple message if dist missing mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { http.NotFound(w, r) return } w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Write([]byte(`
Build the Vue app: cd webapp && bun run build, then run the server from repo root.