diff --git a/ActionResult/IActionResult.go b/ActionResult/IActionResult.go index 06e6692e..a7634c66 100644 --- a/ActionResult/IActionResult.go +++ b/ActionResult/IActionResult.go @@ -13,6 +13,7 @@ type IActionResult interface { func writeContentType(w http.ResponseWriter, value []string) { header := w.Header() if val := header["Content-Type"]; len(val) == 0 { - header["Content-Type"] = value + w.Header().Set("content-type", value[0]) + //header["Content-Type"] = value } } diff --git a/Context/HttpContext.go b/Context/HttpContext.go index 44ab52c8..3f66aa76 100644 --- a/Context/HttpContext.go +++ b/Context/HttpContext.go @@ -352,15 +352,14 @@ func bodyAllowedForStatus(status int) bool { // ActionResult writes the response headers and calls render.ActionResult to render data. func (c *HttpContext) Render(code int, r ActionResult.IActionResult) { - c.Status(code) - if !bodyAllowedForStatus(code) { r.WriteContentType(c.Response) c.Response.WriteHeaderNow() return } - if err := r.Render(c.Response); err != nil { + if err := r.Render(c.Response.ResponseWriter); err != nil { panic(err) } + c.Status(code) } diff --git a/Examples/SimpleWeb/main.go b/Examples/SimpleWeb/main.go index f0690e9c..5be38730 100644 --- a/Examples/SimpleWeb/main.go +++ b/Examples/SimpleWeb/main.go @@ -21,6 +21,7 @@ func main() { //* Create the builder of Web host func CreateCustomBuilder() *YoyoGo.HostBuilder { return YoyoGo.NewWebHostBuilder(). + //UseHttp(). UseFastHttp(). //UseServer(YoyoGo.DefaultHttps(":8080", "./Certificate/server.pem", "./Certificate/server.key")). Configure(func(app *YoyoGo.ApplicationBuilder) { diff --git a/Framework/Version.go b/Framework/Version.go index 67238553..127ade76 100644 --- a/Framework/Version.go +++ b/Framework/Version.go @@ -1,5 +1,5 @@ package YoyoGo const ( - Version = "v1.4.9.2 pre-release" + Version = "v1.4.9.3 pre-release" ) diff --git a/Router/MvcRouterHandler.go b/Router/MvcRouterHandler.go index 3fdf3abc..826a16a9 100644 --- a/Router/MvcRouterHandler.go +++ b/Router/MvcRouterHandler.go @@ -5,7 +5,6 @@ import ( "github.com/maxzhang1985/yoyogo/Context" "github.com/maxzhang1985/yoyogo/Controller" "net/http" - "reflect" "strings" ) @@ -70,10 +69,10 @@ func (handler *MvcRouterHandler) Invoke(ctx *Context.HttpContext, pathComponents } -func findControllerAction() { - t := reflect.ValueOf(method.Object) - method.methodInfo = t.MethodByName(method.MethodName) - if !method.methodInfo.IsValid() { - return false - } -} +//func findControllerAction() { +// t := reflect.ValueOf(method.Object) +// method.methodInfo = t.MethodByName(method.MethodName) +// if !method.methodInfo.IsValid() { +// return false +// } +//}