2017-08-23 09:19:21 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-09-08 06:05:46 +00:00
|
|
|
"flag"
|
2017-08-23 09:19:21 +00:00
|
|
|
|
2017-11-23 08:06:44 +00:00
|
|
|
cc "git.loafle.net/commons_go/config"
|
2017-09-05 06:37:33 +00:00
|
|
|
"git.loafle.net/commons_go/cors_fasthttp"
|
|
|
|
"git.loafle.net/commons_go/logging"
|
2017-11-23 08:06:44 +00:00
|
|
|
"git.loafle.net/overflow/overflow_server_app/config"
|
|
|
|
"git.loafle.net/overflow/overflow_server_app/external"
|
2017-08-23 09:19:21 +00:00
|
|
|
"git.loafle.net/overflow/overflow_server_app/module/member"
|
|
|
|
"git.loafle.net/overflow/overflow_server_app/server"
|
|
|
|
|
|
|
|
"github.com/valyala/fasthttp"
|
|
|
|
)
|
|
|
|
|
2017-11-23 08:06:44 +00:00
|
|
|
func init() {
|
|
|
|
configPath := flag.String(ConfigPathFlagName, "./", "The path of config file")
|
2017-09-08 06:05:46 +00:00
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
|
2017-11-23 08:06:44 +00:00
|
|
|
cc.SetConfigPath(*configPath)
|
|
|
|
if err := cc.Load(&config.Config, ConfigFileName); nil != err {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
2017-08-23 09:19:21 +00:00
|
|
|
|
2017-11-23 08:06:44 +00:00
|
|
|
func main() {
|
|
|
|
defer logging.Logger().Sync()
|
2017-08-23 09:19:21 +00:00
|
|
|
|
2017-11-23 08:06:44 +00:00
|
|
|
external.ExternalInit()
|
2017-08-23 09:19:21 +00:00
|
|
|
|
2017-11-23 08:06:44 +00:00
|
|
|
s := server.New()
|
2018-03-14 09:45:07 +00:00
|
|
|
s.Route("POST", "/account/signin", member.Signin)
|
|
|
|
s.Route("POST", "/account/signin_cookie", member.SigninByCookie)
|
2017-08-31 10:23:38 +00:00
|
|
|
s.Route("POST", "/account/signup", member.SignUp)
|
|
|
|
s.Route("POST", "/account/forgot_password", member.ForgotPassword)
|
|
|
|
s.Route("POST", "/account/reset_password", member.ResetPassword)
|
|
|
|
s.Route("GET", "/account/check_email", member.CheckEmail)
|
2017-08-31 06:37:28 +00:00
|
|
|
|
2017-11-23 08:06:44 +00:00
|
|
|
c := cors_fasthttp.AllowAll()
|
|
|
|
fasthttp.ListenAndServe(config.Config.Server.Addr, c.Handler(s.Handler))
|
2017-09-05 06:37:33 +00:00
|
|
|
|
2017-11-23 08:06:44 +00:00
|
|
|
external.ExternalDestroy()
|
2017-09-05 06:37:33 +00:00
|
|
|
}
|
|
|
|
|
2017-08-31 10:23:38 +00:00
|
|
|
//
|
|
|
|
//func CORS(next server.RequestHandler) server.RequestHandler {
|
|
|
|
// return server.RequestHandler(func(sctx *server.ServerContext, ctx * fasthttp.RequestCtx) {
|
|
|
|
//
|
|
|
|
// ctx.Response.Header.Set("Access-Control-Allow-Credentials", "true" )
|
|
|
|
// ctx.Response.Header.Set("Access-Control-Allow-Headers", "authorization")
|
|
|
|
// ctx.Response.Header.Set("Access-Control-Allow-Methods", "HEAD,GET,POST,PUT,DELETE,OPTIONS" )
|
|
|
|
// ctx.Response.Header.Set("Access-Control-Allow-Origin", "*")
|
|
|
|
//
|
|
|
|
// next(sctx, ctx)
|
|
|
|
// })
|
2017-09-05 06:37:33 +00:00
|
|
|
//}
|