forked from ebhomengo/niki
Merge pull request 'feat: add CORS middleware configuration with custom allowed origins(#154)' (#155) from stage/erfan/add-cors-configuration into develop
Reviewed-on: ebhomengo/niki#155
This commit is contained in:
commit
083327472c
|
@ -10,7 +10,12 @@ import (
|
|||
)
|
||||
|
||||
type HTTPServer struct {
|
||||
Port int `koanf:"port"`
|
||||
Port int `koanf:"port"`
|
||||
Cors Cors `koanf:"cors"`
|
||||
}
|
||||
|
||||
type Cors struct {
|
||||
AllowOrigins []string `koanf:"allow_origins"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
|
|
@ -67,6 +67,9 @@ func (s Server) Serve() {
|
|||
func (s Server) RegisterRoutes() {
|
||||
s.Router.Use(middleware.RequestID())
|
||||
s.Router.Use(middleware.Recover())
|
||||
s.Router.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
||||
AllowOrigins: s.config.HTTPServer.Cors.AllowOrigins,
|
||||
}))
|
||||
registerSwagger(s.Router)
|
||||
|
||||
// Routes
|
||||
|
|
|
@ -3,6 +3,9 @@ type: yml
|
|||
|
||||
http_server:
|
||||
port: 1313
|
||||
cors:
|
||||
allow_origins:
|
||||
- "*"
|
||||
|
||||
benefactor_service:
|
||||
length_of_otp_code: 5
|
||||
|
|
Loading…
Reference in New Issue