2022-04-21 15:14:49 -03:00
|
|
|
package handler
|
|
|
|
|
|
|
|
|
|
import (
|
2023-09-23 17:02:55 +00:00
|
|
|
"encoding/json"
|
2022-04-21 15:14:49 -03:00
|
|
|
"net/http"
|
|
|
|
|
"time"
|
2023-09-23 17:02:55 +00:00
|
|
|
|
|
|
|
|
"github.com/felipemarinho97/torrent-indexer/cache"
|
2022-04-21 15:14:49 -03:00
|
|
|
)
|
|
|
|
|
|
2023-09-23 17:02:55 +00:00
|
|
|
type Indexer struct {
|
|
|
|
|
redis *cache.Redis
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewIndexers(redis *cache.Redis) *Indexer {
|
|
|
|
|
return &Indexer{
|
|
|
|
|
redis: redis,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-21 15:14:49 -03:00
|
|
|
func HandlerIndex(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
currentTime := time.Now().Format(time.RFC850)
|
2023-09-23 17:02:55 +00:00
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
|
json.NewEncoder(w).Encode(map[string]interface{}{
|
|
|
|
|
"time": currentTime,
|
|
|
|
|
"endpoints": map[string]interface{}{
|
|
|
|
|
"/indexers/comando_torrents": map[string]interface{}{
|
|
|
|
|
"method": "GET",
|
|
|
|
|
"description": "Indexer for comando torrents",
|
|
|
|
|
"query_params": map[string]string{
|
|
|
|
|
"q": "search query",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
2022-04-21 15:14:49 -03:00
|
|
|
}
|