-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
38 lines (32 loc) · 961 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"github.com/caarlos0/env"
"log"
"net/http"
"os"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/rs/cors"
)
var Router = mux.NewRouter().StrictSlash(true)
var authCodeConfig struct {
ValidateRedirectURI bool `env:"OAUTH_VALIDATE_REDIRECT_URI" envDefault:"true"`
OauthCodeUi string `env:"OAUTH_CODE_UI" envDefault:"http://localhost:3685"`
AllowOrigin []string `env:"OAUTH_CORS_ALLOW_ORIGIN" envSeparator:"," envDefault:"http://localhost:3685,http://localhost:3001"`
}
func init() {
err := env.Parse(&authCodeConfig)
if err != nil {
log.Printf("%+v\n", err)
}
}
func main() {
log.Println("Started!")
corsRouter := cors.New(cors.Options{
AllowedOrigins: authCodeConfig.AllowOrigin,
AllowCredentials: true,
Debug: true,
}).Handler(Router)
loggedRouter := handlers.LoggingHandler(os.Stdout, corsRouter)
log.Fatal(http.ListenAndServe(":3684", loggedRouter))
}