Account has not been confirmed.
+This login email has been registered but not confirmed. Please check your email (and spam folder). Click here to resend your confirmation email.
++ Back to OSF +
diff --git a/fakecas.go b/fakecas.go index a53624a..9b95ce3 100644 --- a/fakecas.go +++ b/fakecas.go @@ -4,8 +4,11 @@ import ( "flag" "fmt" "github.com/labstack/echo" + "github.com/labstack/echo/engine/standard" mw "github.com/labstack/echo/middleware" + "github.com/rs/cors" "gopkg.in/mgo.v2" + "os" ) var ( @@ -19,17 +22,27 @@ var ( func main() { flag.Parse() e := echo.New() - e.Use(mw.Logger()) + e.Use(mw.LoggerFromConfig(mw.LoggerConfig{ + Format: "${time_rfc3339} ${method} ${uri} ${status} ${response_time} ${response_size}\n", + Output: os.Stdout, + })) e.Use(mw.Recover()) - e.Use(CorsMiddleWare()) + e.Use(standard.WrapMiddleware(cors.New(cors.Options{ + AllowCredentials: true, + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{"GET", "PUT", "POST", "DELETE"}, + AllowedHeaders: []string{"Range", "Content-Type", "Authorization", "X-Requested-With"}, + ExposedHeaders: []string{"Range", "Content-Type", "Authorization", "X-Requested-With"}, + }).Handler)) + + e.Get("/login", Login) e.Post("/login", Login) e.Get("/logout", Logout) e.Get("/oauth2/profile", OAuth) e.Get("/p3/serviceValidate", ServiceValidate) - fmt.Println("Expecting database", *DatabaseName, " to be running at", *DatabaseAddress) - fmt.Println("Listening on", *Host) + fmt.Println("Expecting database", *DatabaseName, "to be running at", *DatabaseAddress) DatabaseSession, err := mgo.Dial(*DatabaseAddress) if err != nil { @@ -39,5 +52,6 @@ func main() { UserCollection = DatabaseSession.DB(*DatabaseName).C("user") - e.Run(*Host) + fmt.Println("Listening on", *Host) + e.Run(standard.New(*Host)) } diff --git a/middleware.go b/middleware.go deleted file mode 100644 index 6b88def..0000000 --- a/middleware.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -import "github.com/labstack/echo" - -func CorsMiddleWare() echo.MiddlewareFunc { - return func(h echo.HandlerFunc) echo.HandlerFunc { - return func(c *echo.Context) error { - c.Response().Header().Add("Access-Control-Allow-Origin", "*") - c.Response().Header().Add("Access-Control-Allow-Headers", "Range, Content-Type, Authorization, Cache-Control, X-Requested-With") - c.Response().Header().Add("Access-Control-Expose-Headers", "Range, Content-Type, Authorization, Cache-Control, X-Requested-With") - c.Response().Header().Add("Cache-control", "no-store, no-cache, must-revalidate, max-age=0") - - if c.Request().Method == "OPTIONS" { - c.Response().Header().Add("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE") - return c.NoContent(204) - } - h(c) - return nil - } - } -} diff --git a/static.go b/static.go new file mode 100644 index 0000000..3fa8474 --- /dev/null +++ b/static.go @@ -0,0 +1,49 @@ +package main + +var UNREGISTERED = `
+ + +This login email has been registered but not confirmed. Please check your email (and spam folder). Click here to resend your confirmation email.
+