diff --git a/configuration_test.go b/configuration_test.go index f5aed4f719..6191501150 100644 --- a/configuration_test.go +++ b/configuration_test.go @@ -30,7 +30,7 @@ func TestConfigurationStatic(t *testing.T) { afterNew = *app.config - if app.config.DisableBodyConsumptionOnUnmarshal == false { + if !app.config.DisableBodyConsumptionOnUnmarshal { t.Fatalf("Passing a Configuration field as Option fails, expected DisableBodyConsumptionOnUnmarshal to be true but was false") } diff --git a/core/router/handler.go b/core/router/handler.go index 18501b398a..b9b79202e9 100644 --- a/core/router/handler.go +++ b/core/router/handler.go @@ -172,6 +172,14 @@ func (h *routerHandler) HandleRequest(ctx context.Context) { r.URL.Path = path url := r.URL.String() + // Fixes https://github.com/kataras/iris/issues/921 + // This is caused for security reasons, imagine a payment shop, + // you can't just permantly redirect a POST request, so just 307 (RFC 7231, 6.4.7). + if method == http.MethodPost || method == http.MethodPut { + ctx.Redirect(url, http.StatusTemporaryRedirect) + return + } + ctx.Redirect(url, http.StatusMovedPermanently) // RFC2616 recommends that a short note "SHOULD" be included in the diff --git a/sessions/sessiondb/redis/service/service.go b/sessions/sessiondb/redis/service/service.go index e48e63de94..34d4f8db7b 100644 --- a/sessions/sessiondb/redis/service/service.go +++ b/sessions/sessiondb/redis/service/service.go @@ -128,10 +128,9 @@ func (r *Service) GetBytes(key string) ([]byte, error) { func (r *Service) Delete(key string) error { c := r.pool.Get() defer c.Close() - if _, err := c.Do("DEL", r.Config.Prefix+key); err != nil { - return err - } - return nil + + _, err := c.Do("DEL", r.Config.Prefix+key) + return err } func dial(network string, addr string, pass string) (redis.Conn, error) { diff --git a/view/handlebars.go b/view/handlebars.go index bfede2beae..68b1fceeba 100644 --- a/view/handlebars.go +++ b/view/handlebars.go @@ -128,7 +128,7 @@ func (s *HandlebarsEngine) loadDirectory() error { // instead of the html/template engine which works like {{ render "myfile.html"}} and accepts the parent binding, with handlebars we can't do that because of lack of runtime helpers (dublicate error) var templateErr error - filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { + filepath.Walk(dir, func(path string, info os.FileInfo, _ error) error { if info == nil || info.IsDir() { return nil }