add scraping the torrent topics rss files

This commit is contained in:
2024-09-09 08:54:29 +03:00
parent 20c4f25c55
commit e587e645fc
26 changed files with 714 additions and 22 deletions

54
internal/http/http.go Normal file
View File

@@ -0,0 +1,54 @@
package http
import (
"log"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/cors"
"git.amok.space/yevhen/resource-scraper/helper/web"
)
/*type Server struct {
router *chi.Mux
}*/
/*type Routes struct {
Api *chi.Mux
}*/
/*type Handler func(w http.ResponseWriter, r *http.Request) error
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if err := h(w, r); err != nil {
w.WriteHeader(http.StatusServiceUnavailable)
_, err := w.Write([]byte("bad"))
if err != nil {
log.Fatalf("Error starting HTTP server: %v", err)
}
}
}*/
func Run() {
port := "19576"
r := chi.NewRouter()
r.Use(cors.Handler(cors.Options{
AllowedOrigins: []string{"https://*", "http://*"},
AllowedMethods: []string{"GET", "POST"},
AllowedHeaders: []string{"*"},
ExposedHeaders: []string{"Link"},
AllowCredentials: false,
MaxAge: 300,
}))
r.Get("/", web.FallbackHandler)
log.Printf("Server starting on port %v", port)
err := http.ListenAndServe("localhost:"+port, r)
if err != nil {
log.Fatalf("Error starting HTTP server: %v", err)
}
}