chg: feat: rewrite to be a torrent indexer

This commit is contained in:
2023-09-23 17:02:55 +00:00
parent c68df1ab37
commit faa721dc19
15 changed files with 711 additions and 389 deletions

View File

@@ -1,16 +1,37 @@
package handler
import (
"fmt"
"encoding/json"
"net/http"
"time"
"github.com/felipemarinho97/torrent-indexer/cache"
)
type Indexer struct {
redis *cache.Redis
}
func NewIndexers(redis *cache.Redis) *Indexer {
return &Indexer{
redis: redis,
}
}
func HandlerIndex(w http.ResponseWriter, r *http.Request) {
currentTime := time.Now().Format(time.RFC850)
fmt.Fprintf(w, currentTime)
w.Header().Set("Content-Type", "text/html")
fmt.Fprintf(w, `
Github OAuth2 => <a href="https://github.com/xjh22222228/github-oauth2" target="_blank">https://github.com/xjh22222228/github-oauth2</a>
`)
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",
},
},
},
})
}