mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-22 08:25:14 +00:00
33 lines
801 B
Go
33 lines
801 B
Go
|
package goscrobble
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/gorilla/mux"
|
||
|
)
|
||
|
|
||
|
// HandleRequests - Boot HTTP server
|
||
|
func HandleRequests() {
|
||
|
// creates a new instance of a mux router
|
||
|
httpRouter := mux.NewRouter().StrictSlash(true)
|
||
|
// replace http.HandleFunc with myRouter.HandleFunc
|
||
|
httpRouter.HandleFunc("/", serveFrontend)
|
||
|
httpRouter.HandleFunc("/api/v1", serveEndpoint)
|
||
|
httpRouter.HandleFunc("/api/v1/scrobble/jellyfin", serveEndpoint)
|
||
|
httpRouter.HandleFunc("/api/v1/jellyfin", serveEndpoint)
|
||
|
|
||
|
// Serve HTTP Server
|
||
|
log.Fatal(http.ListenAndServe(":42069", httpRouter))
|
||
|
}
|
||
|
|
||
|
// serveFrontend - Handle / queries
|
||
|
func serveFrontend(w http.ResponseWriter, r *http.Request) {
|
||
|
fmt.Fprintf(w, "Welcome!")
|
||
|
}
|
||
|
|
||
|
func serveEndpoint(w http.ResponseWriter, r *http.Request) {
|
||
|
fmt.Fprintf(w, "{}")
|
||
|
}
|