Quantcast
Channel: OSCHINA 社区最新新闻
Viewing all articles
Browse latest Browse all 44801

Go 语言极速 web 框架 IRIS V4.6.0 发布

$
0
0

Go 语言极速 web 框架 IRIS V4.1.1 发布了,更新如下:

4.5.2/.3 -> 4.6.0

This update affects only testers who used iris.Tester at the past.

  • FIX: httptest flags caused by httpexpect which used to help you with tests inside old funciris.Tester as reported here

  • NEW: iris.ResetDefault() func which resets the default iris instance which is the station for the most part of the public/package API

  • NEW: package httptest with configuration which can be passed per 'tester' instead of iris instance( this is very helpful for testers)

  • CHANGED: All tests are now converted for 'white-box' testing, means that tests now have package named: iris_test instead of iris in the same main directory.

  • CHANGED: iris.Tester moved to httptest.New which lives inside the new/kataras/iris/httptest package, so:

import (
    "github.com/kataras/iris"
    "testing"
)

func MyTest(t *testing.T) {
    iris.Get("/mypath", func(ctx *iris.Context){
        ctx.Write("my body")
    })
    // with configs: iris.Config.Tester.ExplicitURL/Debug = true
    e:= iris.Tester(t)
    e.GET("/mypath").Expect().Status(iris.StatusOK).Body().Equal("my body")
}

used that instead/new

import (
    "github.com/kataras/iris/httptest"
    "github.com/kataras/iris"
    "testing"
)

func MyTest(t *testing.T) {
    // make sure that you reset your default station if you don't use the form of app := iris.New()
    iris.ResetDefault()

    iris.Get("/mypath", func(ctx *iris.Context){
        ctx.Write("my body")
    })

    e:= httptest.New(iris.Default, t)
    // with configs: e:= httptest.New(iris.Default, t, httptest.ExplicitURL(true), httptest.Debug(true))
    e.GET("/mypath").Expect().Status(iris.StatusOK).Body().Equal("my body")
}

Finally, some plugins container's additions:

  • NEW: iris.Plugins.Len() func which returns the length of the current activated plugins in the default station

  • NEW: iris.Plugins.Fired("event") int func which returns how much times and from how many plugins a particular event type is fired, event types are: "prelookup", "prebuild", "prelisten", "postlisten", "preclose", "predownload"

  • NEW: iris.Plugins.PreLookupFired() bool func which returns true if PreLookup fired at least one time

  • NEW: iris.Plugins.PreBuildFired() bool func which returns true if PreBuild fired at least one time

  • NEW: iris.Plugins.PreListenFired() bool func which returns true ifPreListen/PreListenParallel fired at least one time

  • NEW: iris.Plugins.PostListenFired() bool func which returns true if PostListen fired at least one time

  • NEW: iris.Plugins.PreCloseFired() bool func which returns true if PreClose fired at least one time

  • NEW: iris.Plugins.PreDownloadFired() bool func which returns true if PreDownload fired at least one time

Golang目前已经发展成为非常广泛使用的开发语言,如果你开发WEB、后台服务、API,都可以用到golang。

原先我们用go来开发基于web的应用时,一般会用到net/http包,然后在代码中处理大量相同的事情,如:路由、鉴权等。

现在通过Iris-Go,可以方便的帮助你来开发基于web的应用。

                Name                Description                Usage
Basicauth Middleware                HTTP Basic authenticationexample 1example 2book section
JWT Middleware                JSON Web Tokensexample book section
Cors Middleware                Cross Origin Resource Sharing W3 specificationhow to use
Secure Middleware                Facilitates some quick security winsexample
I18n Middleware                Simple internationalizationexamplebook section
Recovery Middleware                Safety recover the station from panicexample
Logger Middleware                Logs every requestexamplebook section
Profile Middleware                Http profiling for debuggingexample
Editor Plugin                Alm-tools, a typescript online IDE/Editorbook section
Typescript Plugin                Auto-compile client-side typescript filesbook section
OAuth,OAuth2 Plugin                User Authentication was never be easier, supports >27 providersexamplebook section
Iris control Plugin                Basic (browser-based) control over your Iris stationexamplebook section
                Name                Description                Usage
JSON                JSON Serializer (Default)example 1,example 2book section
JSONP                JSONP Serializer (Default)example 1,example 2book section
XML                XML Serializer (Default)example 1,example 2book section
Markdown                Markdown Serializer (Default)example 1,example 2book section
Text                Text Serializer (Default)example 1book section
Binary Data                Binary Data Serializer (Default)example 1book section
                Name                Description                Usage
HTML/Default Engine                HTML Template Engine (Default)example book section
Django Engine                Django Template Engineexample book section
Pug/Jade Engine                Pug Template Engineexample book section
Handlebars Engine                Handlebars Template Engineexample book section
Amber Engine                Amber Template Engineexample book section
Markdown Engine                Markdown Template Engineexample book section

Viewing all articles
Browse latest Browse all 44801

Trending Articles