Fixed CORS-SHIT

This commit is contained in:
konrad 2017-11-10 16:50:09 +01:00 committed by kolaente
parent e70a414b44
commit a5a5cdb84a
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 9 additions and 11 deletions

View File

@ -37,10 +37,6 @@ func RegisterRoutes(e *echo.Echo) {
}
})
// CORS
e.OPTIONS("/login", SetCORSHeader)
e.OPTIONS("/api/v1/books", SetCORSHeader)
// Basic Route
e.Static("/", "assets/index.html")
@ -50,8 +46,16 @@ func RegisterRoutes(e *echo.Echo) {
// API Routes
a := e.Group("/api/v1")
a.POST("/login", Login)
// CORS_SHIT
a.OPTIONS("/books", SetCORSHeader)
a.OPTIONS("/books/:id", SetCORSHeader)
a.OPTIONS("/login", SetCORSHeader)
a.OPTIONS("/authors", SetCORSHeader)
a.OPTIONS("/authors/:id", SetCORSHeader)
a.OPTIONS("/publishers", SetCORSHeader)
a.OPTIONS("/publishers/:id", SetCORSHeader)
a.POST("/login", Login)
// Lookup Books
a.GET("/books", apiv1.BookList)
@ -76,22 +80,16 @@ func RegisterRoutes(e *echo.Echo) {
// Manage Books
a.PUT("/books", apiv1.BookAdd)
a.DELETE("/books/:id", apiv1.BookDelete)
a.OPTIONS("/books", SetCORSHeader)
a.OPTIONS("/books/:id", SetCORSHeader)
// Manage Authors
a.PUT("/authors", apiv1.AuthorAdd)
a.DELETE("/authors/:id", apiv1.AuthorDelete)
a.POST("/authors/:id", apiv1.AuthorUpdate)
a.OPTIONS("/authors", SetCORSHeader)
a.OPTIONS("/authors/:id", SetCORSHeader)
// Manage Publishers
a.PUT("/publishers", apiv1.PublisherAdd)
a.DELETE("/publishers/:id", apiv1.PublisherDelete)
a.POST("/publishers/:id", apiv1.PublisherUpdate)
a.OPTIONS("/publishers", SetCORSHeader)
a.OPTIONS("/publishers/:id", SetCORSHeader)
// Manage Users