Release version 12.2.0-beta2

This commit is contained in:
Gerasimos (Makis) Maropoulos 2022-05-09 03:01:34 +03:00
parent d989044054
commit 02077a01fa
No known key found for this signature in database
GPG Key ID: ACAB76DFB0DD3F3B
9 changed files with 88 additions and 7 deletions

View File

@ -28,6 +28,10 @@ The codebase for Dependency Injection, Internationalization and localization and
## Fixes and Improvements ## Fixes and Improvements
- Fix [#1882](https://github.com/kataras/iris/issues/1882)
- Fix [#1877](https://github.com/kataras/iris/issues/1877)
- Fix [#1876](https://github.com/kataras/iris/issues/1876)
- New `date` dynamic path parameter type. E.g. `/blog/{param:date}` matches to `"/blog/2022/04/21"`. - New `date` dynamic path parameter type. E.g. `/blog/{param:date}` matches to `"/blog/2022/04/21"`.
- Add `iris.AllowQuerySemicolons` and `iris.WithoutServerError(iris.ErrURLQuerySemicolon)` to handle golang.org/issue/25192 as reported at: https://github.com/kataras/iris/issues/1875. - Add `iris.AllowQuerySemicolons` and `iris.WithoutServerError(iris.ErrURLQuerySemicolon)` to handle golang.org/issue/25192 as reported at: https://github.com/kataras/iris/issues/1875.

View File

@ -28,6 +28,7 @@ import "github.com/kataras/iris/v12"
func main() { func main() {
app := iris.New() app := iris.New()
app.Use(iris.Compression)
app.Get("/", func(ctx iris.Context) { app.Get("/", func(ctx iris.Context) {
ctx.HTML("Hello <strong>%s</strong>!", "World") ctx.HTML("Hello <strong>%s</strong>!", "World")
@ -362,7 +363,7 @@ With your help, we can improve Open Source web development for everyone!
$ mkdir myapp $ mkdir myapp
$ cd myapp $ cd myapp
$ go mod init myapp $ go mod init myapp
$ go get github.com/kataras/iris/v12@master # or @v12.2.0-beta1 $ go get github.com/kataras/iris/v12@master # or @v12.2.0-beta2
``` ```
<details><summary>Install on existing project</summary> <details><summary>Install on existing project</summary>

View File

@ -242,7 +242,7 @@ Venkatt Guhesan" title="vguhesan" with="75" style="width:75px;max-width:75px;hei
$ mkdir myapp $ mkdir myapp
$ cd myapp $ cd myapp
$ go mod init myapp $ go mod init myapp
$ go get github.com/kataras/iris/v12@master # or @v12.2.0-alpha8 $ go get github.com/kataras/iris/v12@master # or @v12.2.0-beta2
``` ```
<div dir="rtl"> <div dir="rtl">

View File

@ -106,6 +106,7 @@
* [Swagger](https://github.com/iris-contrib/swagger/tree/master/_examples/basic) * [Swagger](https://github.com/iris-contrib/swagger/tree/master/_examples/basic)
* [Testing](testing/httptest/main_test.go) * [Testing](testing/httptest/main_test.go)
* [Recovery](recover/main.go) * [Recovery](recover/main.go)
* [Panic and custom Error Handler with Compression](recover/panic-and-custom-error-handler-with-compression/main.go)
* [Profiling](pprof/main.go) * [Profiling](pprof/main.go)
* File Server * File Server
* [File Server](file-server/file-server/main.go) * [File Server](file-server/file-server/main.go)

View File

@ -0,0 +1,64 @@
package main
import (
"errors"
"fmt"
"github.com/kataras/iris/v12"
// "github.com/kataras/iris/v12/context"
)
func main() {
app := iris.New()
app.UseRouter(iris.Compression)
app.UseRouter(myErrorHandler)
app.Get("/", handler)
app.Listen(":8080")
}
func myErrorHandler(ctx iris.Context) {
recorder := ctx.Recorder()
defer func() {
var err error
if v := recover(); v != nil { // panic
if panicErr, ok := v.(error); ok {
err = panicErr
} else {
err = errors.New(fmt.Sprint(v))
}
} else { // custom error.
err = ctx.GetErr()
}
if err != nil {
// To keep compression after reset:
// clear body and any headers created between recorder and handler.
recorder.ResetBody()
recorder.ResetHeaders()
//
// To disable compression after reset:
// recorder.Reset()
// recorder.ResponseWriter.(*context.CompressResponseWriter).Disabled = true
//
ctx.StopWithJSON(iris.StatusInternalServerError, iris.Map{
"message": err.Error(),
})
}
}()
ctx.Next()
}
func handler(ctx iris.Context) {
ctx.WriteString("Content may fall")
ctx.Header("X-Test", "value")
// ctx.SetErr(fmt.Errorf("custom error message"))
panic("errr!")
}

View File

@ -841,7 +841,7 @@ func (ctx *Context) StopWithPlainError(statusCode int, err error) {
// it will also fire the specified error code handler. // it will also fire the specified error code handler.
func (ctx *Context) StopWithJSON(statusCode int, jsonObject interface{}) error { func (ctx *Context) StopWithJSON(statusCode int, jsonObject interface{}) error {
ctx.StopWithStatus(statusCode) ctx.StopWithStatus(statusCode)
_, err := ctx.writeJSON(jsonObject, nil) _, err := ctx.writeJSON(jsonObject, nil) // do not modify - see errors.DefaultContextErrorHandler.
return err return err
} }
@ -3975,9 +3975,14 @@ type (
// ErrorHandler describes a context error handler which applies on // ErrorHandler describes a context error handler which applies on
// JSON, JSONP, Protobuf, MsgPack, XML, YAML and Markdown write errors. // JSON, JSONP, Protobuf, MsgPack, XML, YAML and Markdown write errors.
// //
// It does NOT modify or handle the result of Context.GetErr at all,
// use a custom middleware instead if you want to handle the handler-provided custom errors (Context.SetErr)
//
// An ErrorHandler can be registered once via Application.SetErrorHandler method to override the default behavior. // An ErrorHandler can be registered once via Application.SetErrorHandler method to override the default behavior.
// The default behavior is to simply send status internal code error // The default behavior is to simply send status internal code error
// without a body back to the client. // without a body back to the client.
//
// See Application.SetContextErrorHandler for more.
ErrorHandler interface { ErrorHandler interface {
HandleContextError(ctx *Context, err error) HandleContextError(ctx *Context, err error)
} }

View File

@ -143,6 +143,11 @@ func (w *ResponseRecorder) ClearHeaders() {
// Reset clears headers, sets the status code to 200 // Reset clears headers, sets the status code to 200
// and clears the cached body. // and clears the cached body.
// //
// - Use ResetBody() and ResetHeaders() instead to keep compression after reseting.
//
// - Use Reset() & ResponseRecorder.ResponseWriter.(*context.CompressResponseWriter).Disabled = true
// to set a new body without compression when the previous handler was iris.Compression.
//
// Implements the `ResponseWriterReseter`. // Implements the `ResponseWriterReseter`.
func (w *ResponseRecorder) Reset() bool { func (w *ResponseRecorder) Reset() bool {
w.ClearHeaders() w.ClearHeaders()

2
doc.go
View File

@ -38,7 +38,7 @@ Source code and other details for the project are available at GitHub:
Current Version Current Version
12.2.0-beta1 12.2.0-beta2
Installation Installation

View File

@ -39,7 +39,7 @@ import (
) )
// Version is the current version of the Iris Web Framework. // Version is the current version of the Iris Web Framework.
const Version = "12.2.0-beta1" const Version = "12.2.0-beta2"
// Byte unit helpers. // Byte unit helpers.
const ( const (
@ -146,7 +146,7 @@ func Default() *Application {
app.logger.Debugf(`Log level set to "debug"`) app.logger.Debugf(`Log level set to "debug"`)
// Register the accesslog middleware. // Register the accesslog middleware.
logFile, err := os.OpenFile("./access.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600) logFile, err := os.OpenFile("./access.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600)
if err == nil { if err == nil {
// Close the file on shutdown. // Close the file on shutdown.
app.ConfigureHost(func(su *Supervisor) { app.ConfigureHost(func(su *Supervisor) {
@ -945,7 +945,8 @@ func TLS(addr string, certFileOrContents, keyFileOrContents string, hostConfigs
func AutoTLS( func AutoTLS(
addr string, addr string,
domain string, email string, domain string, email string,
hostConfigs ...host.Configurator) Runner { hostConfigs ...host.Configurator,
) Runner {
return func(app *Application) error { return func(app *Application) error {
return app.NewHost(&http.Server{Addr: addr}). return app.NewHost(&http.Server{Addr: addr}).
Configure(hostConfigs...). Configure(hostConfigs...).