diff --git a/README.md b/README.md index e17b2319..3d705364 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,73 @@ -

+

+ - Logo created by an Iris community member, https://github.com/OneebMalik +
+Iris is an efficient and well-designed toolbox with robust set of features. Write your own +perfect high-performance web applications with unlimited potentials. +
+ +If you're coming from Node.js world, this is the expressjs equivalent for the Go Programming Language. +
Build Status http://goreportcard.com/report/kataras/iris Iris support forum Built with GoLang +CHANGELOG/HISTORY +Examples for new Gophers +Docs +Chat Buy me a cup of coffee -

+
+This benchmark measures results from 'real-world' instead of 'hello-world' application source code. | Last Update At: July 21, 2016. | Shows: Processing Time Horizontal Graph. | Who did Transparency:  Third-party source | Iris version: these benchmark results are totally valid for v5. | New (go 1.8 + iris.v6) benchmarks will be published on the next techempower's fortune! -Iris is an efficient and well-designed toolbox with robust set of features.
Write your own -perfect high-performance web applications
with unlimited potentials and portability. -

+

+ + +What you say about Iris ✌ +----------- +

+ + + + + + + -If you're coming from Node.js world, this is the expressjs equivalent for the Go Programming Language.
+ + + + + + + +
- + + + +What people say + + + +What people say +

-Heroes [♡](https://github.com/kataras/iris#support) + + +Legends [♡](https://github.com/kataras/iris#support) ----------- [Juan Sebastián Suárez Valencia](https://github.com/Juanses) donated 20 EUR at September 11 of 2016 @@ -109,22 +148,6 @@ $ go get gopkg.in/kataras/iris.v6 For further installation support, navigate [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework). -Documentation ------------ - - - -- Godocs ⇒ https://godoc.org/gopkg.in/kataras/iris.v6 - -- Getting Started with Go+Iris ⇒ http://gopherbook.iris-go.com - -- Navigate through community examples ⇒ https://github.com/iris-contrib/examples - -- [./adaptors](https://github.com/kataras/iris/tree/v6/adaptors) and [./middleware](https://github.com/kataras/iris/tree/v6/middleware) contains examples of their usage. - -- [HISTORY.md](https://github.com//kataras/iris/tree/v6/HISTORY.md) is your best friend, version migrations are released there. - - Overview ----------- @@ -248,6 +271,91 @@ app.Adapt(view.HTML("./views", ".html").Reload(true)) ``` +FAQ & Documentation +----------- + + + +- [Getting Started with Go+Iris](http://gopherbook.iris-go.com). + +- [Godocs](https://godoc.org/gopkg.in/kataras/iris.v6) for deep documentation. + +- Official small but practical [examples](https://github.com/kataras/iris/tree/v6/_examples). + +- Navigate through [community examples](https://github.com/iris-contrib/examples) too. + +- [DZone: A URL Shortener Service Using Go, Iris, and Bolt](https://dzone.com/articles/a-url-shortener-service-using-go-iris-and-bolt-ger?oid=twitter&utm_content=buffera2aca&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer). + +- [./adaptors](https://github.com/kataras/iris/tree/v6/adaptors) and [./middleware](https://github.com/kataras/iris/tree/v6/middleware) contains examples of their usage. + +- [HISTORY.md](https://github.com//kataras/iris/tree/v6/HISTORY.md) is your best friend, version migrations are released there. + + +I'll be glad to talk with you about **your awesome feature requests**, +open a new [discussion](http://support.iris-go.com), you will be heard! + + + +Support +------------ + +- [Star the project](https://github.com/kataras/iris/strangers), will help you to follow the upcoming features. +- Write [an article](https://dzone.com/articles/a-url-shortener-service-using-go-iris-and-bolt-ger) about Iris or even [post a Tweet](https://twitter.com/gelnior/status/769100480706379776). +- Report bugs by opening an new topic labeled as 'bug' [here](http://support.iris-go.com), thanks! + + + + + +Buy me a cup of coffee? +------------ + +Iris is free and open source but developing it has taken thousands of hours of my time and a large part of my sanity. If you feel this web framework useful to you, it would go a great way to ensuring that I can afford to take the time to continue to develop it. + + +I spend all my time in the construction of Iris, therefore I have no income value. + +Feel free to send **any** amount through paypal + +[![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.me/kataras/) + +> Please check your e-mail after your donation. + + +Thanks for your gratitude and finance help ♡ + + + + + + + Third Party Middleware ------------ @@ -277,18 +385,14 @@ Here is a small list of Iris compatible middleware, I'm sure you can find more! | [digits](https://github.com/bamarni/digits) | [Bilal Amarni](https://github.com/bamarni) | Middleware that handles [Twitter Digits](https://get.digits.com/) authentication | + Testing ------------ @@ -374,23 +479,16 @@ i.e: - [policy_gorillamux_test.go](https://github.com/kataras/iris/blob/v6/policy_gorillamux_test.go) - [policy_httprouter_test.go](https://github.com/kataras/iris/blob/v6/policy_httprouter_test.go) - [policy_nativerouter_test.go](https://github.com/kataras/iris/blob/v6/policy_nativerouter_test.go) -- [policy_render_test.go](https://github.com/kataras/iris/blob/v6/policy_render_test.go) +- [policy_routerwrapper_test.go](https://github.com/kataras/iris/blob/v6/policy_routerwrapper_test.go) - [policy_sessions_test.go](https://github.com/kataras/iris/blob/v6/policy_sessions_test.go) - [response_writer_test.go](https://github.com/kataras/iris/blob/v6/response_writer_test.go) - [route_test.go](https://github.com/kataras/iris/blob/v6/route_test.go) - [status_test.go](https://github.com/kataras/iris/blob/v6/status_test.go) - [transaction_test.go](https://github.com/kataras/iris/blob/v6/transaction_test.go) +- [serializer_test.go](https://github.com/kataras/iris/blob/v6/serializer_test.go) A simple test is located to [./httptest/_example/main_test.go](https://github.com/kataras/iris/blob/v6/httptest/_example/main_test.go) -httpexpect's repository has some Iris examples too: - -- https://github.com/gavv/httpexpect/blob/master/_examples/iris.go (without `httptest` package) -- https://github.com/gavv/httpexpect/blob/master/_examples/iris_test.go (without `httptest` package) - -Read more about httpexpect [here](https://github.com/gavv/httpexpect). - - Philosophy ------------ @@ -407,61 +505,6 @@ The author of Iris is [@kataras](https://github.com/kataras). However the real Success of Iris belongs to you with your bug reports and feature requests that made this Framework so Unique. -Support ------------- - - - -The main purpose of donations to open source is to say "thank you" to the developer rather than actually advancing the project. - -Open source projects don’t need the money like those charities do—and so it’s usually phrased like: *Buy the developer a cup of coffee*. - - -### Buy me a cup of coffee? - -Iris is free and open source but developing it has taken thousands of hours of my time and a large part of my sanity. If you feel this web framework useful to you, it would go a great way to ensuring that I can afford to take the time to continue to develop it. - -Thanks for your gratitude and finance help ♡ - -[![](https://raw.githubusercontent.com/iris-contrib/website/gh-pages/assets/donate.png)](https://www.paypal.me/kataras/25eur) - - -Some of the benefits are listed here: - -- Your github username, after your approval, is visible at the top of the README page. -- Access to the 'donors' [private chat room](https://kataras.rocket.chat/group/donors) gives you real-time assistance by Iris' Author. - - -> *ANONYMOUS*: People who donate but don't want to be shown here. -*ANONYMOUS* are listed as one group instead of an individual entry, in order to protect their exact date of their donation. - -> The names, shown at the [supporters](https://github.com/kataras/iris#heroes-) list, are sorted by **date** and **NOT by the amount** of the donation. - -### More options! - -- Star the project, will help you to follow the upcoming features. -- Write an article about Iris or even post a Tweet. -- If you are interested in contributing to the Iris project, please see the document [CONTRIBUTING](https://github.com/kataras/iris/blob/master/.github/CONTRIBUTING.md). - - -### Become An Iris Sponsor - -Want to add your company's logo to our [website](http://iris-go.com)? - -Please contact me via email: kataras2006@hotmail.com - -Thank you! - - Socialize ------------ diff --git a/_future/macros_test.go b/_future/macros_test.go new file mode 100644 index 00000000..5634ba28 --- /dev/null +++ b/_future/macros_test.go @@ -0,0 +1,75 @@ +package router + +import ( + "regexp" + "testing" +) + +// macros should be registered before .Listen +type _macros map[string]func(string) bool + +// a helper to return a macro from a simple regexp +// it compiles the regexp and after returns the macro, for obviously performance reasons. +func fromRegexp(expr string) func(paramValue string) bool { + if expr == "" { + panic("empty expr on regex") + } + + // add the last $ if missing (and not wildcard(?)) + if i := expr[len(expr)-1]; i != '$' && i != '*' { + expr += "$" + } + + r, err := regexp.Compile(expr) + if err != nil { + panic(err) + } + + return r.MatchString +} + +// link the path tmpl with macros, at .Boot time, before Listen. +// make it a as middleware from the beginning and prepend that before the main handler. +func link(path string, m _macros) { + tmpl, err := ParsePath(path) + if err != nil { + panic(err) + } + // link the path, based on its template with a macro + // and return a new compiled macro or a list of iris handlers + // in order to be prepended on the original route or make a different function for that? + // we'll see. + _ = tmpl + +} + +// eval runs while serving paths +// instead of path it can receive the iris.Context and work as middleware +// if the macro passed completely then do ctx.Next() to continue to the main handler and the following, +// otherwise ctx.EmitError(pathTmpl.FailStatusCode) , which defaults to 404 for normal behavior on not found a route, +// but the developer can change that too, +// for example in order to fire the 402 if the compiled macro(I should think the name later) failed to be evaluted +// then the user should add !+statuscode, i.e "{id:int !402}". +// func eval(path string, tmpl *PathTmpl) bool { +// return false +// } +// <--- fun(c)k it, we will do it directly to be iris' middleware or create a new type which will save a macro and tries to eval it with a path +// only for test-cases? and after on iris we can make a middleware from this, I should think it more when I stop the drinking. + +func testMacros(source string) error { + var m = _macros{ + "id": fromRegexp("[1-9]+$"), + } + + link(source, m) + + // eval("/api/users/42", result) + + return nil +} + +func TestMacros(t *testing.T) { + if err := testMacros("/api/users/{id:int}/posts"); err != nil { + t.Fatal(err) + } +}