New create and return DotApp instance default run mode is RunMode_Production
()
| 94 | // New create and return DotApp instance |
| 95 | // default run mode is RunMode_Production |
| 96 | func New() *DotWeb { |
| 97 | app := &DotWeb{ |
| 98 | HttpServer: NewHttpServer(), |
| 99 | Middlewares: make([]Middleware, 0), |
| 100 | Items: core.NewConcurrenceMap(), |
| 101 | Config: config.NewConfig(), |
| 102 | middlewareMap: make(map[string]MiddlewareFunc), |
| 103 | middlewareMutex: new(sync.RWMutex), |
| 104 | pluginMap: make(map[string]Plugin), |
| 105 | pluginMutex: new(sync.RWMutex), |
| 106 | StartMode: StartMode_New, |
| 107 | serverStateInfo: core.NewServerStateInfo(), |
| 108 | } |
| 109 | // set default run mode = RunMode_Production |
| 110 | app.Config.App.RunMode = RunMode_Production |
| 111 | app.HttpServer.setDotApp(app) |
| 112 | // add default httphandler with middlewares |
| 113 | // fixed for issue #100 |
| 114 | app.Use(&xMiddleware{}) |
| 115 | |
| 116 | // init logger |
| 117 | app.appLog = logger.NewAppLog() |
| 118 | |
| 119 | return app |
| 120 | } |
| 121 | |
| 122 | // Classic create and return DotApp instance\ |
| 123 | // if set logPath = "", it will use bin-root/logs for log-root |