-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
45 lines (39 loc) · 1.04 KB
/
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
39
40
41
42
43
44
45
package main
import (
"net/http"
"github.com/ZettaAI/auth-server/authenticate"
"github.com/ZettaAI/auth-server/providers"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
var corsConfig = middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{
http.MethodGet,
http.MethodHead,
http.MethodPut,
http.MethodPatch,
http.MethodPost,
http.MethodDelete,
},
AllowHeaders: []string{echo.HeaderAuthorization},
ExposeHeaders: []string{
echo.HeaderContentType,
echo.HeaderContentLength,
echo.HeaderContentEncoding,
echo.HeaderAccept,
echo.HeaderWWWAuthenticate,
},
}
func main() {
e := echo.New()
e.Use(middleware.CORSWithConfig(corsConfig))
e.GET("/", func(c echo.Context) error {
return c.String(http.StatusOK, "Hello, World!")
})
e.GET(authenticate.AuthEP, authenticate.Login)
e.GET(authenticate.AuthLogoutEP, authenticate.Logout)
e.GET(providers.GoogleOAuthLoginEP, providers.GoogleLogin)
e.GET(providers.GoogleOAuthCallbackEP, providers.GoogleCallback)
e.Logger.Fatal(e.Start(":8000"))
}