chg: feat: rewrite to be a torrent indexer
This commit is contained in:
33
api/index.go
33
api/index.go
@@ -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",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user