All checks were successful
gitea/video-server-backend/pipeline/head This commit looks good
31 lines
647 B
Go
31 lines
647 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"video_server_backend/api/handler"
|
|
"video_server_backend/api/middleware"
|
|
)
|
|
|
|
func notFoundHandler(w http.ResponseWriter, r *http.Request) {
|
|
http.Error(w, "Endpoint not found", http.StatusNotFound)
|
|
}
|
|
|
|
func createMux() *http.ServeMux {
|
|
var mux *http.ServeMux = http.NewServeMux()
|
|
mux.HandleFunc("/video", handler.StreamVideoHandler)
|
|
mux.HandleFunc("/search", handler.SearchVideoHandler)
|
|
mux.HandleFunc("/", notFoundHandler)
|
|
|
|
return mux
|
|
}
|
|
|
|
func createHandler() http.Handler {
|
|
return middleware.AddCORSHeaders(createMux())
|
|
}
|
|
|
|
func main() {
|
|
log.Fatal(http.ListenAndServe(":8080", createHandler()))
|
|
}
|