Skip to content

Commit

Permalink
Merge pull request #204 for v0.11.2 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm authored Jul 28, 2018
2 parents f7bf268 + 767dee5 commit aa1960d
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 43 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<p align="center">Visit aah's official website https://aahframework.org to learn more</p>
</p>
<p align="center">
<p align="center"><a href="https://travis-ci.org/go-aah/aah"><img src="https://travis-ci.org/go-aah/aah.svg?branch=master" alt="Build Status"></a> <a href="https://codecov.io/gh/go-aah/aah/branch/master"><img src="https://codecov.io/gh/go-aah/aah/branch/master/graph/badge.svg" alt="Code Coverage"></a> <a href="https://goreportcard.com/report/aahframework.org/aah.v0"><img src="https://goreportcard.com/badge/aahframework.org/aah.v0" alt="Go Report Card"></a> <a href="https://github.com/go-aah/aah/releases/latest"><img src="https://img.shields.io/badge/version-0.11.1-blue.svg" alt="Release Version"></a> <a href="https://godoc.org/aahframework.org/aah.v0"><img src="https://godoc.org/aahframework.org/aah.v0?status.svg" alt="Godoc"></a> <a href="https://hub.docker.com/r/aahframework/aah/"><img src="https://img.shields.io/docker/pulls/aahframework/aah.svg" alt="Docker Pulls"></a> <a href="https://twitter.com/aahframework"><img src="https://img.shields.io/badge/twitter-@aahframework-55acee.svg" alt="Twitter @aahframework"></a></p>
<p align="center"><a href="https://travis-ci.org/go-aah/aah"><img src="https://travis-ci.org/go-aah/aah.svg?branch=master" alt="Build Status"></a> <a href="https://codecov.io/gh/go-aah/aah/branch/master"><img src="https://codecov.io/gh/go-aah/aah/branch/master/graph/badge.svg" alt="Code Coverage"></a> <a href="https://goreportcard.com/report/aahframework.org/aah.v0"><img src="https://goreportcard.com/badge/aahframework.org/aah.v0" alt="Go Report Card"></a> <a href="https://github.com/go-aah/aah/releases/latest"><img src="https://img.shields.io/badge/version-0.11.2-blue.svg" alt="Release Version"></a> <a href="https://godoc.org/aahframework.org/aah.v0"><img src="https://godoc.org/aahframework.org/aah.v0?status.svg" alt="Godoc"></a> <a href="https://hub.docker.com/r/aahframework/aah/"><img src="https://img.shields.io/docker/pulls/aahframework/aah.svg" alt="Docker Pulls"></a> <a href="https://twitter.com/aahframework"><img src="https://img.shields.io/badge/twitter-@aahframework-55acee.svg" alt="Twitter @aahframework"></a></p>
</p>

### News

* `v0.11.1` [released](https://docs.aahframework.org/release-notes.html) and tagged on Jul 22, 2018.
* `v0.11.2` [released](https://docs.aahframework.org/release-notes.html) and tagged on Jul 27, 2018.

### Stargazers over time

Expand Down
3 changes: 2 additions & 1 deletion aah.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,8 @@ func (a *app) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

if isWebSocket(r) {
upgrade := r.Header.Get(ahttp.HeaderUpgrade)
if upgrade == "websocket" || upgrade == "Websocket" {
a.wse.Handle(w, r)
return
}
Expand Down
21 changes: 2 additions & 19 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,10 @@ func (ctx *Context) setTarget(route *router.Route) error {
}

target := reflect.New(ctx.controller.Type)
ctx.target = target.Interface()

// check action method exists or not
ctx.actionrv = reflect.ValueOf(target.Interface()).MethodByName(ctx.action.Name)
ctx.actionrv = reflect.ValueOf(ctx.target).MethodByName(ctx.action.Name)
if !ctx.actionrv.IsValid() {
return errTargetNotFound
}
Expand All @@ -307,7 +308,6 @@ func (ctx *Context) setTarget(route *router.Route) error {
targetElem.FieldByIndex(index).Set(ctxrv)
}

ctx.target = target.Interface()
ctx.targetrv = reflect.ValueOf(ctx.target)
return nil
}
Expand Down Expand Up @@ -387,20 +387,3 @@ func (ctx *Context) writeHeaders() {
func (ctx *Context) hasAccess() (bool, []*authz.Reason) {
return ctx.route.HasAccess(ctx.Subject())
}

// callAction method calls targed action method on the controller.
func (ctx *Context) callAction() {
// Parse Action Parameters
actionArgs, err := ctx.parseParameters()
if err != nil { // Any error of parameter parsing result in 400 Bad Request
ctx.Reply().BadRequest().Error(err)
return
}

ctx.Log().Debugf("Calling action: %s.%s", ctx.controller.FqName, ctx.action.Name)
if ctx.actionrv.Type().IsVariadic() {
ctx.actionrv.CallSlice(actionArgs)
} else {
ctx.actionrv.Call(actionArgs)
}
}
11 changes: 9 additions & 2 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,15 @@ func ActionMiddleware(ctx *Context, m *Middleware) {
}
}

// Calls controller action
ctx.callAction()
// Parse Action Parameters
actionArgs, err := ctx.parseParameters()
if err != nil { // Any error of parameter parsing result in 400 Bad Request
ctx.Reply().BadRequest().Error(err)
return
}

ctx.Log().Debugf("Calling action: %s.%s", ctx.controller.FqName, ctx.action.Name)
ctx.actionrv.Call(actionArgs)

// After action method
if !ctx.abort {
Expand Down
14 changes: 7 additions & 7 deletions render.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type textRender struct {
}

// textRender method writes given text into HTTP response.
func (t textRender) Render(w io.Writer) (err error) {
func (t *textRender) Render(w io.Writer) (err error) {
if len(t.Values) > 0 {
_, err = fmt.Fprintf(w, t.Format, t.Values...)
} else {
Expand All @@ -82,7 +82,7 @@ type jsonRender struct {
}

// Render method writes JSON into HTTP response.
func (j jsonRender) Render(w io.Writer) error {
func (j *jsonRender) Render(w io.Writer) error {
return json.NewEncoder(w).Encode(j.Data)
}

Expand All @@ -97,7 +97,7 @@ type jsonpRender struct {
}

// Render method writes JSONP into HTTP response.
func (j jsonpRender) Render(w io.Writer) error {
func (j *jsonpRender) Render(w io.Writer) error {
jsonBytes, err := json.Marshal(j.Data)
if err != nil {
return err
Expand All @@ -121,7 +121,7 @@ type secureJSONRender struct {
Data interface{}
}

func (s secureJSONRender) Render(w io.Writer) error {
func (s *secureJSONRender) Render(w io.Writer) error {
if _, err := w.Write([]byte(s.Prefix)); err != nil {
return err
}
Expand All @@ -138,7 +138,7 @@ type xmlRender struct {
}

// Render method writes XML into HTTP response.
func (x xmlRender) Render(w io.Writer) error {
func (x *xmlRender) Render(w io.Writer) error {
if _, err := w.Write(xmlHeaderBytes); err != nil {
return err
}
Expand Down Expand Up @@ -186,7 +186,7 @@ type binaryRender struct {
}

// Render method writes File into HTTP response.
func (f binaryRender) Render(w io.Writer) error {
func (f *binaryRender) Render(w io.Writer) error {
if f.Reader != nil {
defer ess.CloseQuietly(f.Reader)
_, err := io.Copy(w, f.Reader)
Expand Down Expand Up @@ -225,7 +225,7 @@ type htmlRender struct {
}

// Render method renders the HTML template into HTTP response.
func (h htmlRender) Render(w io.Writer) error {
func (h *htmlRender) Render(w io.Writer) error {
if h.Template == nil {
return errors.New("template is nil")
}
Expand Down
6 changes: 3 additions & 3 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,9 @@ func (a *app) findRouteURLDomain(host, routeName string) (*router.Domain, string
}

// Returning requested subdomain
for k, v := range a.Router().Domains {
if strings.HasPrefix(k, subDomain) && v.IsSubDomain {
return v, routeName[idx+1:]
for _, d := range a.Router().Domains {
if strings.HasPrefix(d.Key, subDomain) && d.IsSubDomain {
return d, routeName[idx+1:]
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func (a *app) Start() {
}

a.Log().Info("App Route Domains:")
for _, name := range a.Router().DomainAddresses() {
a.Log().Infof(" Host: %s, CORS Enabled: %t", name, a.Router().Domains[name].CORSEnabled)
for _, d := range a.Router().Domains {
a.Log().Infof(" Host: %s, CORS Enabled: %t", d.Name, d.CORSEnabled)
}

redirectEnabled := a.Config().BoolDefault("server.redirect.enable", false)
Expand Down
6 changes: 0 additions & 6 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ func wrapGzipWriter(res ahttp.ResponseWriter) ahttp.ResponseWriter {
return ahttp.WrapGzipWriter(res)
}

// IsWebSocket method returns true if request is WebSocket otherwise false.
func isWebSocket(r *http.Request) bool {
return strings.ToLower(r.Header.Get(ahttp.HeaderUpgrade)) == "websocket" &&
strings.Contains(strings.ToLower(r.Header.Get(ahttp.HeaderConnection)), "upgrade")
}

func inferRedirectMode(redirectTo string) string {
if redirectTo == www {
return nonwww + " ==> " + www
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
package aah

// Version no. of aah framework
const Version = "0.11.1"
const Version = "0.11.2"

0 comments on commit aa1960d

Please sign in to comment.