forked from goffee/core
start cookie session
This commit is contained in:
parent
465e88bf40
commit
2bffdcdcf7
5 changed files with 275 additions and 7 deletions
8
core.go
8
core.go
|
|
@ -98,9 +98,7 @@ func (app *App) Run(router *httprouter.Router) {
|
|||
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
|
||||
// if enabled,
|
||||
if TemplateEnable {
|
||||
// add public path
|
||||
publicPath := os.Getenv("TEMPLATE_PUBLIC")
|
||||
router.ServeFiles("/public/*filepath", http.Dir(publicPath))
|
||||
router.ServeFiles("/public/*filepath", http.Dir("storage/public"))
|
||||
}
|
||||
|
||||
useHttpsStr := os.Getenv("App_USE_HTTPS")
|
||||
|
|
@ -183,6 +181,7 @@ func (app *App) RegisterRoutes(routes []Route, router *httprouter.Router) *httpr
|
|||
|
||||
func (app *App) makeHTTPRouterHandlerFunc(h Controller, ms []Hook) httprouter.Handle {
|
||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
|
||||
ctx := &Context{
|
||||
Request: &Request{
|
||||
httpRequest: r,
|
||||
|
|
@ -206,11 +205,13 @@ func (app *App) makeHTTPRouterHandlerFunc(h Controller, ms []Hook) httprouter.Ha
|
|||
GetEventsManager: resolveEventsManager(),
|
||||
GetLogger: resolveLogger(),
|
||||
}
|
||||
|
||||
ctx.prepare(ctx)
|
||||
rhs := app.combHandlers(h, ms)
|
||||
app.prepareChain(rhs)
|
||||
app.t = 0
|
||||
app.chain.execute(ctx)
|
||||
|
||||
for _, header := range ctx.Response.headers {
|
||||
w.Header().Add(header.key, header.val)
|
||||
}
|
||||
|
|
@ -223,6 +224,7 @@ func (app *App) makeHTTPRouterHandlerFunc(h Controller, ms []Hook) httprouter.Ha
|
|||
} else {
|
||||
ct = CONTENT_TYPE_HTML
|
||||
}
|
||||
|
||||
w.Header().Add(CONTENT_TYPE, ct)
|
||||
if ctx.Response.statusCode != 0 {
|
||||
w.WriteHeader(ctx.Response.statusCode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue