Add OPTIONS to / and /upload endpoints

This commit is contained in:
James Mills 2020-03-25 07:36:23 +10:00
parent b6f36d2738
commit 3d0b3044ec
No known key found for this signature in database
GPG key ID: AC4C014F1440EBD6

View file

@ -76,8 +76,8 @@ func NewApp(cfg *Config) (*App, error) {
// Setup Router // Setup Router
r := mux.NewRouter().StrictSlash(true) r := mux.NewRouter().StrictSlash(true)
r.HandleFunc("/", a.indexHandler).Methods("GET") r.HandleFunc("/", a.indexHandler).Methods("GET", "OPTIONS")
r.HandleFunc("/upload", a.uploadHandler).Methods("GET", "POST") r.HandleFunc("/upload", a.uploadHandler).Methods("GET", "OPTIONS", "POST")
r.HandleFunc("/v/{id}.mp4", a.videoHandler).Methods("GET") r.HandleFunc("/v/{id}.mp4", a.videoHandler).Methods("GET")
r.HandleFunc("/v/{prefix}/{id}.mp4", a.videoHandler).Methods("GET") r.HandleFunc("/v/{prefix}/{id}.mp4", a.videoHandler).Methods("GET")
r.HandleFunc("/t/{id}", a.thumbHandler).Methods("GET") r.HandleFunc("/t/{id}", a.thumbHandler).Methods("GET")
@ -93,7 +93,7 @@ func NewApp(cfg *Config) (*App, error) {
r.PathPrefix("/static/").Handler(fsHandler).Methods("GET") r.PathPrefix("/static/").Handler(fsHandler).Methods("GET")
cors := handlers.CORS( cors := handlers.CORS(
handlers.AllowedHeaders([]string{"Content-Type"}), handlers.AllowedHeaders([]string{"content-type"}),
handlers.AllowedOrigins([]string{"*"}), handlers.AllowedOrigins([]string{"*"}),
handlers.AllowCredentials(), handlers.AllowCredentials(),
) )