Adding prefix /api/v1/
This commit is contained in:
parent
24a4ace616
commit
e6e3cc1196
@ -7,7 +7,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/jackc/pgx/v4"
|
"github.com/jackc/pgx/v4"
|
||||||
@ -64,13 +63,6 @@ func gettrends() {
|
|||||||
|
|
||||||
func trending(w http.ResponseWriter, r *http.Request) {
|
func trending(w http.ResponseWriter, r *http.Request) {
|
||||||
enableCors(&w)
|
enableCors(&w)
|
||||||
|
|
||||||
if strings.Contains(r.Header.Get("Accept"), "application/json") {
|
|
||||||
log.Print("Treat as an Json")
|
|
||||||
} else {
|
|
||||||
log.Println("Treat as HTML")
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Fprintf(w, "%s", trendingexport)
|
fmt.Fprintf(w, "%s", trendingexport)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,12 +71,6 @@ func search(w http.ResponseWriter, r *http.Request) {
|
|||||||
searchkeys, exists_search := r.URL.Query()["s"]
|
searchkeys, exists_search := r.URL.Query()["s"]
|
||||||
offsetkeys, exists_offset := r.URL.Query()["o"]
|
offsetkeys, exists_offset := r.URL.Query()["o"]
|
||||||
|
|
||||||
if strings.Contains(r.Header.Get("Accept"), "application/json") {
|
|
||||||
log.Print("Treat as an Json")
|
|
||||||
} else {
|
|
||||||
log.Println("Treat as HTML")
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
var rows pgx.Rows
|
var rows pgx.Rows
|
||||||
var searchKey string
|
var searchKey string
|
||||||
@ -164,8 +150,8 @@ func main() {
|
|||||||
|
|
||||||
go gettrends()
|
go gettrends()
|
||||||
|
|
||||||
http.HandleFunc("/search", search)
|
http.HandleFunc("/api/v1/search", search)
|
||||||
http.HandleFunc("/trending", trending)
|
http.HandleFunc("/api/v1/trending", trending)
|
||||||
log.Print("Starting HTTP inbox on port http://0.0.0.0:6431")
|
log.Print("Starting HTTP inbox on port http://0.0.0.0:6431")
|
||||||
log.Fatal(http.ListenAndServe("0.0.0.0:6431", nil))
|
log.Fatal(http.ListenAndServe("0.0.0.0:6431", nil))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user