Allow API versioning (#85)

* add api v3 partial support.

* fix codecs in env.

* fix default codecs.

* split files.

* add session stats for api v3.

* fix API token env.

* fix null array in json.

* add CORS.

* save api version to labels.

* irgnore api token env.

* remove duplicate api version.

* move api version to settings.
This commit is contained in:
Miroslav Šedivý
2023-10-21 21:26:02 +02:00
committed by GitHub
parent 93c1e6fef8
commit 47ee523205
9 changed files with 545 additions and 210 deletions
+12 -8
View File
@@ -45,14 +45,18 @@ func New(ApiManager types.ApiManager, roomConfig *config.Room, config *config.Se
router.Use(middleware.Recoverer) // Recover from panics without crashing server
// Basic CORS
// for more ideas, see: https://developer.github.com/v3/#cross-origin-resource-sharing
router.Use(cors.Handler(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
AllowCredentials: true,
MaxAge: 300, // Maximum value not ignored by any of major browsers
}))
if config.CORS {
// for more ideas, see: https://developer.github.com/v3/#cross-origin-resource-sharing
router.Use(cors.Handler(cors.Options{
AllowOriginFunc: func(r *http.Request, origin string) bool {
return true
},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
AllowCredentials: true,
MaxAge: 300, // Maximum value not ignored by any of major browsers
}))
}
// mount pprof endpoint
if config.PProf {