2026-05-23 20:32:12 +08:00
|
|
|
package router
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
|
"github.com/volcano-tts/tts-api/controller"
|
|
|
|
|
"github.com/volcano-tts/tts-api/middleware"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Setup() *mux.Router {
|
|
|
|
|
r := mux.NewRouter()
|
|
|
|
|
|
|
|
|
|
r.Use(middleware.CORS)
|
2026-05-24 15:33:27 +08:00
|
|
|
r.Use(middleware.SecurityHeaders)
|
2026-05-23 20:32:12 +08:00
|
|
|
r.Use(middleware.Logger)
|
|
|
|
|
|
|
|
|
|
r.HandleFunc("/v1/audio/speech", controller.OpenaiTTSHandler).Methods("POST", "OPTIONS")
|
|
|
|
|
r.HandleFunc("/health", controller.HealthHandler).Methods("GET")
|
|
|
|
|
r.HandleFunc("/dashboard", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
http.ServeFile(w, r, "health.html")
|
|
|
|
|
}).Methods("GET")
|
|
|
|
|
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
http.Redirect(w, r, "/dashboard", http.StatusFound)
|
|
|
|
|
}).Methods("GET")
|
|
|
|
|
|
|
|
|
|
return r
|
|
|
|
|
}
|