mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +01:00
re-write the wikis for the upcoming version. About, Installation, Support, Getting Started and Routing sections completed.
parent
3534cb9476
commit
6abc331464
44
About.md
Normal file
44
About.md
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
Iris is a fast, simple yet fully featured and very efficient web framework written in [Go](https://golang.org).
|
||||||
|
|
||||||
|
Iris provides a beautifully expressive and easy to use foundation for your next website or API.
|
||||||
|
|
||||||
|
Iris offers a complete and decent support to its users.
|
||||||
|
|
||||||
|
## Our Philosophy
|
||||||
|
|
||||||
|
The Iris philosophy is to provide robust tooling for HTTP, making it a great solution for single page applications, web sites, hybrids, or public HTTP APIs. Keep note that, so far, iris is the fastest web framework ever created in terms of real-world performance.
|
||||||
|
|
||||||
|
Iris does not force you to use any specific ORM or template engine. With support for the most powerful and fast template engines, you can quickly craft the perfect application.
|
||||||
|
|
||||||
|
## Why Yet Another Web Framework?
|
||||||
|
|
||||||
|
Go is a great technology stack for building scalable, web-based, back-end systems for web
|
||||||
|
applications.
|
||||||
|
|
||||||
|
When you think about building web applications and web APIs, or simply building HTTP servers in Go, does your mind go to the standard net/http package?
|
||||||
|
Then you have to deal with some common situations like dynamic routing (a.k.a parameterized), security and authentication, real-time communication and many other issues that net/http doesn't solve.
|
||||||
|
|
||||||
|
The net/http package is not complete enough to quickly build well-designed back-end web systems. When you realize this, you might be thinking along these lines:
|
||||||
|
|
||||||
|
- Ok, the net/http package doesn't suit me, but there are so many frameworks, which one will work for me?!
|
||||||
|
- Each one of them tells me that it is the best. I don't know what to do!
|
||||||
|
|
||||||
|
### The truth
|
||||||
|
|
||||||
|
I did some deep research and benchmarks with [wrk](https://github.com/wg/wrk) and [ab](https://httpd.apache.org/docs/2.4/programs/ab.html) in order to choose which framework suits me and my new project. The results, unfortunately, were really disappointing to me.
|
||||||
|
|
||||||
|
I started wondering if Golang wasn't as fast for net or http applications as I was reading from different kind of online sources... but right before I leave Golang for good and continue to develop with nodejs and .net core, I whispered to myself:
|
||||||
|
|
||||||
|
> Makis, don't lose hope, give at least a chance to Golang. Try to build something totally new without basing it off the "slow" code you saw earlier; learn the secrets of this language and make *others* follow your steps!
|
||||||
|
|
||||||
|
These are the words I told myself that day [**13 March 2016**].
|
||||||
|
|
||||||
|
The same day, later the night, I was reading a book about Greek mythology. I saw an ancient goddess name there and I was immediately inspired to give her name to this new web framework I was already started to design and code - **Iris**.
|
||||||
|
|
||||||
|
Some weeks later, Iris was trending on position #1 in Github for **all languages**, this is very rare phenomenon especially for a new personal project, back then, with such a young developer behind it. After that, as was reasonable, competitors who couldn't handle their losses, and individuals with low self-esteem began to pull out themselves and their jealousy about the success of others, started to randomly throw defamations and fake news around. Of course they never even thought to argument on the fact that Iris the fastest and greatest in terms of performance and features because numbers never lie and their whole narrative would fall very fast. Instead they try to bullying me through my personality, they tried to put me down in order to stop the active development of Iris -- But of course they didn't know me well back then, I'm overwhelmingly compassionate and righteous person but softiness does not belong in my characteristics. They think that they deserve the same reputation because they think they work hard too but, sadly, they can't realize a simple fact of life: they don't work hard enough to release a succeed product that people will immediately fall in love, trust and use on their jobs and this is the most important reason behind their hatred for success.
|
||||||
|
|
||||||
|
However, I strongly believe that we should not respond back with the same coin, instead, I think we should prove them that compassion and love live inside each one of us, by forgiving them and their actions and look forward for a better place to express ourselves without fear and racism.
|
||||||
|
|
||||||
|
Nowadays, Iris is more popular than ever. In fact, their posts, unintentionally, made Iris even more popular than it already was and people started to be very supportive to my dream and this is the reason we are still here.
|
||||||
|
|
||||||
|
Do you want to find out how supportive Iris is as a return? You can continue reading our [[Support]] section.
|
3
Documentation-terms-and-conditions.md
Normal file
3
Documentation-terms-and-conditions.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
The technical documentation on this wiki is published under the terms of the Creative Commons Attribution-ShareAlike 4.0 International Public Licence available at:
|
||||||
|
|
||||||
|
https://creativecommons.org/licenses/by-sa/4.0/legalcode.
|
43
Features.md
43
Features.md
|
@ -1,43 +0,0 @@
|
||||||
# 🔥 Hot Features
|
|
||||||
|
|
||||||
- Focus on high performance
|
|
||||||
- Easy Fluent API
|
|
||||||
- Highly customizable
|
|
||||||
- Robust routing and middleware ecosystem
|
|
||||||
* Build RESTful APIs with iris unique expressionist path interpreter
|
|
||||||
* Dynamic path parameterized or wildcard routes are not conflict with static routes
|
|
||||||
* Remove trailing slash from the URL with option to redirect
|
|
||||||
* Virtual hosts and subdomains made easy
|
|
||||||
* Group API's and static or even dynamic subdomains
|
|
||||||
* `net/http` and `negroni-like` handlers are compatible via `iris.FromStd`
|
|
||||||
* Register custom handlers for any HTTP error
|
|
||||||
* Transactions and rollback when you need it
|
|
||||||
* Cache the response when you need it
|
|
||||||
* A single function to serve your embedded assets, always compatible with `go-bindata`
|
|
||||||
* HTTP to HTTPS
|
|
||||||
* HTTP to HTTPS WWW
|
|
||||||
* [learn the reasons that differ from what you've seen so far](https://github.com/kataras/iris/tree/master/_examples/#routing-grouping-dynamic-path-parameters-macros-and-custom-context)
|
|
||||||
* MVC **NEW**
|
|
||||||
- Context
|
|
||||||
* Highly scalable rich content render (Markdown, JSON, JSONP, XML...)
|
|
||||||
* Body binders and handy functions to send HTTP responses
|
|
||||||
* Limit request body
|
|
||||||
* Serve static resources or embedded assets
|
|
||||||
* Localization i18N
|
|
||||||
* Compression (Gzip is built'n)
|
|
||||||
- Authentication
|
|
||||||
* Basic Authentication
|
|
||||||
* OAuth, OAuth2 supporting 27+ popular websites
|
|
||||||
* JWT
|
|
||||||
- Server
|
|
||||||
* Automatically install and serve certificates from https://letsencrypt.org when serving via TLS
|
|
||||||
* Gracefully shutdown by-default
|
|
||||||
* Register on shutdown, error or interrupt events
|
|
||||||
* Attach more than one server, fully compatible with `net/http#Server`
|
|
||||||
- View system: supporting 5 template engines. Fully compatible with `html/template`
|
|
||||||
- HTTP Sessions library [you can still use your favorite if you want to]
|
|
||||||
- Websocket library, its API similar to socket.io [you can still use your favorite if you want to]
|
|
||||||
- Hot Reload on source code changes[*](https://github.com/kataras/rizla)
|
|
||||||
- Typescript integration + Web IDE
|
|
||||||
|
|
||||||
Iris is one of the most featured web frameworks out there, not all features are here and don't expect from me to write down all of their usages in this gitbook, if you see that I'm missing something please make a PR to the [book repository](https://github.com/kataras/build-a-better-web-together).
|
|
100
Getting-started.md
Normal file
100
Getting-started.md
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
Iris has an expressive syntax for routing which feels like home. The routing algorithm is powered by the [muxie project](https://github.com/kataras/muxie) which handles requests and matches routes faster than its alternatives like httprouter and gin or echo.
|
||||||
|
|
||||||
|
Let's get started without any hassle.
|
||||||
|
|
||||||
|
Create an empty file, let's assume its name is `example.go`, then open it and copy-paste the below code.
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/kataras/iris"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := iris.Default()
|
||||||
|
app.Use(myMiddleware)
|
||||||
|
|
||||||
|
app.Handle("GET", "/ping", func(ctx iris.Context) {
|
||||||
|
ctx.JSON(iris.Map{"message": "pong"})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Listens and serves incoming http requests
|
||||||
|
// on http://localhost:8080.
|
||||||
|
app.Run(iris.Addr(":8080"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func myMiddleware(ctx iris.Context) {
|
||||||
|
ctx.Application().Logger().Infof("Runs before %s", ctx.Path())
|
||||||
|
ctx.Next()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Start a terminal session and execute the following.
|
||||||
|
|
||||||
|
```
|
||||||
|
# run example.go and visit http://localhost:8080/ping on browser
|
||||||
|
$ go run example.go
|
||||||
|
```
|
||||||
|
|
||||||
|
## Show me more!
|
||||||
|
|
||||||
|
Let's take a small overview of how easy is to get up and running.
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/kataras/iris"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := iris.New()
|
||||||
|
// Load all templates from the "./views" folder
|
||||||
|
// where extension is ".html" and parse them
|
||||||
|
// using the standard `html/template` package.
|
||||||
|
app.RegisterView(iris.HTML("./views", ".html"))
|
||||||
|
|
||||||
|
// Method: GET
|
||||||
|
// Resource: http://localhost:8080
|
||||||
|
app.Get("/", func(ctx iris.Context) {
|
||||||
|
// Bind: {{.message}} with "Hello world!"
|
||||||
|
ctx.ViewData("message", "Hello world!")
|
||||||
|
// Render template file: ./views/hello.html
|
||||||
|
ctx.View("hello.html")
|
||||||
|
})
|
||||||
|
|
||||||
|
// Method: GET
|
||||||
|
// Resource: http://localhost:8080/user/42
|
||||||
|
//
|
||||||
|
// Need to use a custom regexp instead?
|
||||||
|
// Easy;
|
||||||
|
// Just mark the parameter's type to 'string'
|
||||||
|
// which accepts anything and make use of
|
||||||
|
// its `regexp` macro function, i.e:
|
||||||
|
// app.Get("/user/{id:string regexp(^[0-9]+$)}")
|
||||||
|
app.Get("/user/{id:uint64}", func(ctx iris.Context) {
|
||||||
|
userID, _ := ctx.Params().GetUint64("id")
|
||||||
|
ctx.Writef("User ID: %d", userID)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Start the server using a network address.
|
||||||
|
app.Run(iris.Addr(":8080"))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- file: ./views/hello.html -->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Hello Page</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>{{.message}}</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
![overview screen](https://github.com/kataras/build-a-better-web-together/raw/master/overview_screen_1.png)
|
||||||
|
|
||||||
|
> Wanna re-start your app automatically when source code changes happens? Install the [rizla](https://github.com/kataras/rizla) tool and execute `rizla main.go` instead of `go run main.go`.
|
||||||
|
|
||||||
|
----------------
|
||||||
|
|
||||||
|
At the next section we will learn more about [[Routing]].
|
206
Home.md
206
Home.md
|
@ -1,196 +1,20 @@
|
||||||
Installation
|
Welcome to **Iris** - the fastest backend web framework for [Go](https://golang.org).
|
||||||
------------
|
|
||||||
|
|
||||||
The only requirement is [Go 1.9](https://golang.org/dl)
|
This wiki is the main source of documentation for **developers** working with (or contributing to) the Iris project.
|
||||||
|
|
||||||
```bash
|
## Table of Contents
|
||||||
$ go get -u github.com/kataras/iris/...
|
|
||||||
```
|
|
||||||
|
|
||||||
Iris takes advantage of the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature. You get truly reproducible builds, as this method guards against upstream renames and deletes.
|
* [[About]]
|
||||||
|
* [[Support]]
|
||||||
|
* [[Installing Iris|Installation]]
|
||||||
|
* [[Getting Started]]
|
||||||
|
* [[Routing]]
|
||||||
|
* [[Path Parameter Types|Routing-path-parameter-types]]
|
||||||
|
* [[Reverse Lookups|Routing-reverse-lookups]]
|
||||||
|
* [[Use and Write middleware|Routing-middleware]]
|
||||||
|
* [[Custom error handlers|Routing-error-handlers]]
|
||||||
|
* [[Wrap the Router|Routing-wrap-the-router]]
|
||||||
|
|
||||||
Getting Started
|
## Runnable Examples
|
||||||
------------
|
|
||||||
|
|
||||||
```go
|
We've crafted more than 100 ready to run examples for your learning curve. Navigate through <https://github.com/kataras/iris/tree/master/_examples>.
|
||||||
package main
|
|
||||||
|
|
||||||
import "github.com/kataras/iris"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
app := iris.New()
|
|
||||||
// Load all templates from the "./views" folder
|
|
||||||
// where extension is ".html" and parse them
|
|
||||||
// using the standard `html/template` package.
|
|
||||||
app.RegisterView(iris.HTML("./views", ".html"))
|
|
||||||
|
|
||||||
// Method: GET
|
|
||||||
// Resource: http://localhost:8080
|
|
||||||
app.Get("/", func(ctx iris.Context) {
|
|
||||||
// Bind: {{.message}} with "Hello world!"
|
|
||||||
ctx.ViewData("message", "Hello world!")
|
|
||||||
// Render template file: ./views/hello.html
|
|
||||||
ctx.View("hello.html")
|
|
||||||
})
|
|
||||||
|
|
||||||
// Method: GET
|
|
||||||
// Resource: http://localhost:8080/user/42
|
|
||||||
//
|
|
||||||
// Need to use a custom regexp instead?
|
|
||||||
// Easy;
|
|
||||||
// Just mark the parameter's type to 'string'
|
|
||||||
// which accepts anything and make use of
|
|
||||||
// its `regexp` macro function, i.e:
|
|
||||||
// app.Get("/user/{id:string regexp(^[0-9]+$)}")
|
|
||||||
app.Get("/user/{id:long}", func(ctx iris.Context) {
|
|
||||||
userID, _ := ctx.Params().GetInt64("id")
|
|
||||||
ctx.Writef("User ID: %d", userID)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Start the server using a network address.
|
|
||||||
app.Run(iris.Addr(":8080"))
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
> Learn more about path parameter's types by clicking [here](https://github.com/kataras/iris/blob/master/_examples/routing/dynamic-path/main.go#L31)
|
|
||||||
|
|
||||||
```html
|
|
||||||
<!-- file: ./views/hello.html -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Hello Page</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>{{.message}}</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
![overview screen](https://github.com/kataras/build-a-better-web-together/raw/master/overview_screen_1.png)
|
|
||||||
|
|
||||||
> Wanna re-start your app automatically when source code changes happens? Install the [rizla](https://github.com/kataras/rizla) tool and execute `rizla main.go` instead of `go run main.go`.
|
|
||||||
|
|
||||||
Table of Contents
|
|
||||||
------------
|
|
||||||
|
|
||||||
<a href ="https://iris-go.com/v8/recipe"> <img align="right" alt="Book cover" src="https://raw.githubusercontent.com/kataras/build-a-better-web-together/master/cover.jpg" width="300" /></a>
|
|
||||||
|
|
||||||
* [Why a new web framework](Why.md)
|
|
||||||
* [Features](Features.md)
|
|
||||||
* [Versioning](Versioning.md)
|
|
||||||
* [Overview](https://github.com/kataras/iris/tree/master/_examples/#overview)
|
|
||||||
* [Hello world!](https://github.com/kataras/iris/blob/master/_examples/hello-world/main.go)
|
|
||||||
* [Glimpse](https://github.com/kataras/iris/blob/master/_examples/overview/main.go)
|
|
||||||
* [Tutorial: Online Visitors](https://github.com/kataras/iris/blob/master/_examples/tutorial/online-visitors)
|
|
||||||
* [Tutorial: URL Shortener using BoltDB](https://medium.com/@kataras/a-url-shortener-service-using-go-iris-and-bolt-4182f0b00ae7)
|
|
||||||
* [Tutorial: DropzoneJS + Go: How to build a file upload form](https://hackernoon.com/how-to-build-a-file-upload-form-using-dropzonejs-and-go-8fb9f258a991)
|
|
||||||
* [Structuring](https://github.com/kataras/iris/tree/master/_examples/#structuring)
|
|
||||||
* [Bootstrapper](https://github.com/kataras/iris/blob/master/_examples/structuring/bootstrap/bootstrap)
|
|
||||||
* [MVC with Repository and Service layer Overview](https://github.com/kataras/iris/tree/master/mvc/overview)
|
|
||||||
* [Login (MVC with Single Responsibility package)](https://github.com/kataras/iris/tree/master/structuring/login-mvc-single-responsible-package)
|
|
||||||
* [Login (MVC with Datamodels, Datasource, Repository and Service layer)](https://github.com/kataras/iris/tree/master/mvc/login)
|
|
||||||
* [HTTP Listening](https://github.com/kataras/iris/tree/master/_examples/#http-listening)
|
|
||||||
* [Common, with address](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-addr/main.go)
|
|
||||||
* [UNIX socket file](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-unix/main.go)
|
|
||||||
* [TLS](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-tls/main.go)
|
|
||||||
* [Letsencrypt (Automatic Certifications)](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-letsencrypt/main.go)
|
|
||||||
* [Custom net.Listener](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-listener/main.go)
|
|
||||||
* [SO_REUSEPORT for unix systems](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-listener/unix-reuseport/main.go)
|
|
||||||
* [Omit server errors](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-addr/omit-server-errors/main.go)
|
|
||||||
* [Custom HTTP Server](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-httpserver/easy-way/main.go)
|
|
||||||
* [Custom HTTP Server (STD)](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-httpserver/std-way/main.go)
|
|
||||||
* [Multi HTTP Servers](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-httpserver/multi/main.go)
|
|
||||||
* [Graceful Shutdown](https://github.com/kataras/iris/blob/master/_examples/http-listening/graceful-shutdown/default-notifier/main.go)
|
|
||||||
* [Configuration](https://github.com/kataras/iris/tree/master/_examples/#configuration)
|
|
||||||
* [Functional](https://github.com/kataras/iris/blob/master/_examples/configuration/functional/main.go)
|
|
||||||
* [From Configuration Struct](https://github.com/kataras/iris/blob/master/_examples/configuration/from-configuration-structure/main.go)
|
|
||||||
* [Import from YAML file](https://github.com/kataras/iris/blob/master/_examples/configuration/from-yaml-file/main.go)
|
|
||||||
* [Import from TOML file](https://github.com/kataras/iris/blob/master/_examples/configuration/from-toml-file/main.go)
|
|
||||||
* [Routing](https://github.com/kataras/iris/tree/master/_examples/#routing-grouping-dynamic-path-parameters-macros-and-custom-context)
|
|
||||||
* [Overview](https://github.com/kataras/iris/blob/master/_examples/routing/overview/main.go)
|
|
||||||
* [Basic](https://github.com/kataras/iris/blob/master/_examples/routing/basic/main.go)
|
|
||||||
* [Custom HTTP Errors](https://github.com/kataras/iris/blob/master/_examples/routing/http-errors/main.go)
|
|
||||||
* [Dynamic Path](https://github.com/kataras/iris/blob/master/_examples/routing/dynamic-path/main.go)
|
|
||||||
* [Root level wildcard path](https://github.com/kataras/iris/blob/master/_examples/routing/dynamic-path/root-wildcard/main.go)
|
|
||||||
* [Reverse routing](https://github.com/kataras/iris/blob/master/_examples/routing/reverse/main.go)
|
|
||||||
* [Custom wrapper](https://github.com/kataras/iris/blob/master/_examples/routing/custom-wrapper/main.go)
|
|
||||||
* [Route State](https://github.com/kataras/iris/blob/master/_examples/routing/route-state/main.go)
|
|
||||||
* [MVC](https://github.com/kataras/iris/tree/master/_examples/#mvc)
|
|
||||||
* [Hello world](https://github.com/kataras/iris/tree/master/_examples/mvc/hello-world)
|
|
||||||
* [Session Controller](https://github.com/kataras/iris/tree/master/_examples/mvc/session-controller)
|
|
||||||
* [Overview - Plus Repository and Service layers](https://github.com/kataras/tree/tree/master/_examples/mvc/overview)
|
|
||||||
* [Login showcase - Plus Repository and Service layers](https://github.com/kataras/iris/tree/master/_examples/mvc/login)
|
|
||||||
* [Custom Context](https://github.com/kataras/iris/tree/master/_examples/routing/custom-context)
|
|
||||||
* [Method Overriding](https://github.com/kataras/iris/blob/master/_examples/routing/custom-context/method-overriding/main.go)
|
|
||||||
* [New Implementation](https://github.com/kataras/iris/blob/master/_examples/routing/custom-context/new-implementation/main.go)
|
|
||||||
* [Convert http.Handler](https://github.com/kataras/iris/tree/master/_examples/convert-handlers)
|
|
||||||
* [From func(http.ResponseWriter, *http.Request, http.HandlerFunc)](convert-handlers/negroni-like/main.go)
|
|
||||||
* [From http.Handler or http.HandlerFunc](convert-handlers/nethttp/main.go)
|
|
||||||
* [Subdomains](subdomains)
|
|
||||||
* [Single](https://github.com/kataras/iris/blob/master/_examples/subdomains/single/main.go)
|
|
||||||
* [Multi](https://github.com/kataras/iris/blob/master/_examples/subdomains/multi/main.go)
|
|
||||||
* [Wildcard](https://github.com/kataras/iris/blob/master/_examples/subdomains/wildcard/main.go)
|
|
||||||
* [WWW](https://github.com/kataras/iris/blob/master/_examples/subdomains/www/main.go)
|
|
||||||
* [View](https://github.com/kataras/iris/tree/master/_examples/#view)
|
|
||||||
* [Overview](https://github.com/kataras/iris/blob/master/_examples/view/overview/main.go)
|
|
||||||
* [Hi](https://github.com/kataras/iris/blob/master/_examples/view/template_html_0/main.go)
|
|
||||||
* [A simple Layout](https://github.com/kataras/iris/blob/master/_examples/view/template_html_1/main.go)
|
|
||||||
* [Layouts: `yield` and `render` tmpl funcs](https://github.com/kataras/iris/blob/master/_examples/view/template_html_2/main.go)
|
|
||||||
* [The `urlpath` tmpl func](https://github.com/kataras/iris/blob/master/_examples/view/template_html_3/main.go)
|
|
||||||
* [The `url` tmpl func](https://github.com/kataras/iris/blob/master/_examples/view/template_html_4/main.go)
|
|
||||||
* [Inject Data Between Handlers](https://github.com/kataras/iris/blob/master/_examples/view/context-view-data/main.go)
|
|
||||||
* [Embedding Templates Into App Executable File](https://github.com/kataras/iris/blob/master/_examples/view/embedding-templates-into-app/main.go)
|
|
||||||
* [Authentication](https://github.com/kataras/iris/tree/master/_examples/#authentication)
|
|
||||||
* [Basic Authentication](https://github.com/kataras/iris/blob/master/_examples/authentication/basicauth/main.go)
|
|
||||||
* [OAUth2](https://github.com/kataras/iris/blob/master/_examples/authentication/oauth2/main.go)
|
|
||||||
* [JWT](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/jwt/simple/main.go)
|
|
||||||
* [File Server](https://github.com/kataras/iris/tree/master/_examples/#file-server)
|
|
||||||
* [Favicon](https://github.com/kataras/iris/blob/master/_examples/file-server/favicon/main.go)
|
|
||||||
* [Basic](https://github.com/kataras/iris/blob/master/_examples/file-server/basic/main.go)
|
|
||||||
* [Embedding Files Into App Executable File](https://github.com/kataras/iris/blob/master/_examples/file-server/embedding-files-into-app/main.go)
|
|
||||||
* [Send/Force-Download Files](https://github.com/kataras/iris/blob/master/_examples/file-server/send-files/main.go)
|
|
||||||
* [Single Page Applications](https://github.com/kataras/iris/tree/master/_examples/file-server/single-page-application)
|
|
||||||
* [Single Page Application](https://github.com/kataras/iris/blob/master/_examples/file-server/single-page-application/basic/main.go)
|
|
||||||
* [Embedded Single Page Application](https://github.com/kataras/iris/blob/master/_examples/file-server/single-page-application/embedded-single-page-application/main.go)
|
|
||||||
* [Embedded Single Page Application with other routes](https://github.com/kataras/iris/blob/master/_examples/file-server/single-page-application/embedded-single-page-application-with-other-routes/main.go)
|
|
||||||
* [How to Read from *http.Request`](https://github.com/kataras/iris/tree/master/_examples/#how-to-read-from-contextrequest-httprequest)
|
|
||||||
* [Bind JSON](https://github.com/kataras/iris/blob/master/_examples/http_request/read-json/main.go)
|
|
||||||
* [Bind Form](https://github.com/kataras/iris/blob/master/_examples/http_request/read-form/main.go)
|
|
||||||
* [Upload/Read Files](https://github.com/kataras/iris/blob/master/_examples/http_request/upload-files/main.go)
|
|
||||||
* [How to Write to http.ResponseWriter](https://github.com/kataras/iris/tree/master/_examples/#how-to-write-to-contextresponsewriter-httpresponsewriter)
|
|
||||||
* [Write `valyala/quicktemplate` templates](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/quicktemplate/main.go)
|
|
||||||
* [Text, Markdown, HTML, JSON, JSONP, XML, Binary](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/write-rest/main.go)
|
|
||||||
* [Stream Writer](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/stream-writer/main.go)
|
|
||||||
* [Transactions](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/transactions/main.go)
|
|
||||||
* [Miscellaneous](https://github.com/kataras/iris/blob/master/_examples/#miscellaneous)
|
|
||||||
* [Request Logger](https://github.com/kataras/iris/blob/master/_examples/http_request/request-logger/main.go)
|
|
||||||
* [Log Requests to a file](https://github.com/kataras/iris/blob/master/_examples/http_request/request-logger/request-logger-file/main.go)
|
|
||||||
* [Localization and Internationalization](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/i18n/main.go)
|
|
||||||
* [Recovery](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/recover/main.go)
|
|
||||||
* [Profiling (pprof)](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/pprof/main.go)
|
|
||||||
* [Internal Application File Logger](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/file-logger/main.go)
|
|
||||||
* [Testing](https://github.com/kataras/iris/blob/master/_examples/testing/httptest/main_test.go)
|
|
||||||
* [Caching](https://github.com/kataras/iris/blob/master/_examples/cache/simple/main.go)
|
|
||||||
* [Yaag - API Automated Docs](https://github.com/kataras/iris/blob/master/_examples/apidoc/yaag/main.go)
|
|
||||||
* [Sessions](https://github.com/kataras/iris/blob/master/_examples/#sessions)
|
|
||||||
* [Overview](https://github.com/kataras/iris/blob/master/_examples/sessions/overview/main.go)
|
|
||||||
* [Standalone](https://github.com/kataras/iris/blob/master/_examples/sessions/standalone/main.go)
|
|
||||||
* [Secure Cookie](https://github.com/kataras/iris/blob/master/_examples/sessions/securecookie/main.go)
|
|
||||||
* [Flash Messages](https://github.com/kataras/iris/blob/master/_examples/sessions/flash-messages/main.go)
|
|
||||||
* [Database](https://github.com/kataras/iris/blob/master/_examples/sessions/database/main.go)
|
|
||||||
* [Websockets](https://github.com/kataras/iris/tree/master/_examples/#websockets)
|
|
||||||
* [Chat](https://github.com/kataras/iris/blob/master/_examples/websocket/chat/main.go)
|
|
||||||
* [Native Messages](https://github.com/kataras/iris/blob/master/_examples/websocket/native-messages/main.go)
|
|
||||||
* [Connection List](https://github.com/kataras/iris/blob/master/_examples/websocket/connectionlist/main.go)
|
|
||||||
* [TLS Enabled](https://github.com/kataras/iris/blob/master/_examples/websocket/secure/main.go)
|
|
||||||
* [Custom Raw Go Client](https://github.com/kataras/iris/blob/master/_examples/websocket/custom-go-client/main.go)
|
|
||||||
* [Experimental Handlers](https://github.com/kataras/iris/tree/master/_examples/experimental-handlers)
|
|
||||||
* [Casbin wrapper](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/casbin/wrapper/main.go)
|
|
||||||
* [Casbin middleware](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/casbin/middleware/main.go)
|
|
||||||
* [Cloudwatch](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/cloudwatch/simple/main.go)
|
|
||||||
* [CORS](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/cors/simple/main.go)
|
|
||||||
* [JWT](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/jwt/main.go)
|
|
||||||
* [Newrelic](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/newrelic/simple/main.go)
|
|
||||||
* [Prometheus](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/prometheus/simple/main.go)
|
|
||||||
* [Secure](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/secure/simple/main.go)
|
|
||||||
* [Tollboothic](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/tollboothic/limit-handler/main.go)
|
|
14
Installation.md
Normal file
14
Installation.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
Iris is a cross-platform software.
|
||||||
|
|
||||||
|
The only requirement is the [Go Programming Language](https://golang.org/dl).
|
||||||
|
|
||||||
|
Start a terminal session and execute:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# downloads and installs the latest version of Iris go package
|
||||||
|
$ go get -u github.com/kataras/iris
|
||||||
|
```
|
||||||
|
|
||||||
|
Iris takes advantage of the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature. You get truly reproducible builds, as this method guards against upstream renames and deletes.
|
||||||
|
|
||||||
|
Continue by reading our [[Getting Started]] tutorial.
|
7
Our-users.md
Normal file
7
Our-users.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
That's a new section we've added to help you publish your work with Iris and Go Community.
|
||||||
|
|
||||||
|
Simply edit this wiki page and add your own in a list-based form.
|
||||||
|
|
||||||
|
---------------
|
||||||
|
|
||||||
|
- your project name or website
|
20
Project-and-community.md
Normal file
20
Project-and-community.md
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
Proud to be involved in developing, releasing and nurturing open source projects, helping to build and sustain developer-based communities around them.
|
||||||
|
|
||||||
|
Let's build the future of web together.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
To get involved, share your ideas, and collaborate with us, head to our [Contributing](https://github.com/kataras/iris/blob/master/CONTRIBUTING.md) home page.
|
||||||
|
|
||||||
|
## Tell the world
|
||||||
|
|
||||||
|
Using Iris in your company or a projects of yours? Add your site [to our list](Our-users)!
|
||||||
|
|
||||||
|
## Improve Iris
|
||||||
|
|
||||||
|
* [Ticket system][issues] - report bugs and make feature requests
|
||||||
|
* Chat to us - in our #iris_go channel on [Gitter](https://gitter.im/iris_go/community)
|
||||||
|
* [Iris wiki][wiki] - fork it to contribute tips and documentation
|
||||||
|
|
||||||
|
[issues]: https://github.com/kataras/iris/issues
|
||||||
|
[wiki]: https://github.com/kataras/iris/wiki
|
196
README.md
196
README.md
|
@ -1,196 +0,0 @@
|
||||||
Installation
|
|
||||||
------------
|
|
||||||
|
|
||||||
The only requirement is [Go 1.9](https://golang.org/dl)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ go get -u github.com/kataras/iris/...
|
|
||||||
```
|
|
||||||
|
|
||||||
Iris takes advantage of the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature. You get truly reproducible builds, as this method guards against upstream renames and deletes.
|
|
||||||
|
|
||||||
Getting Started
|
|
||||||
------------
|
|
||||||
|
|
||||||
```go
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "github.com/kataras/iris"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
app := iris.New()
|
|
||||||
// Load all templates from the "./views" folder
|
|
||||||
// where extension is ".html" and parse them
|
|
||||||
// using the standard `html/template` package.
|
|
||||||
app.RegisterView(iris.HTML("./views", ".html"))
|
|
||||||
|
|
||||||
// Method: GET
|
|
||||||
// Resource: http://localhost:8080
|
|
||||||
app.Get("/", func(ctx iris.Context) {
|
|
||||||
// Bind: {{.message}} with "Hello world!"
|
|
||||||
ctx.ViewData("message", "Hello world!")
|
|
||||||
// Render template file: ./views/hello.html
|
|
||||||
ctx.View("hello.html")
|
|
||||||
})
|
|
||||||
|
|
||||||
// Method: GET
|
|
||||||
// Resource: http://localhost:8080/user/42
|
|
||||||
//
|
|
||||||
// Need to use a custom regexp instead?
|
|
||||||
// Easy;
|
|
||||||
// Just mark the parameter's type to 'string'
|
|
||||||
// which accepts anything and make use of
|
|
||||||
// its `regexp` macro function, i.e:
|
|
||||||
// app.Get("/user/{id:string regexp(^[0-9]+$)}")
|
|
||||||
app.Get("/user/{id:long}", func(ctx iris.Context) {
|
|
||||||
userID, _ := ctx.Params().GetInt64("id")
|
|
||||||
ctx.Writef("User ID: %d", userID)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Start the server using a network address.
|
|
||||||
app.Run(iris.Addr(":8080"))
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
> Learn more about path parameter's types by clicking [here](https://github.com/kataras/iris/blob/master/_examples/routing/dynamic-path/main.go#L31)
|
|
||||||
|
|
||||||
```html
|
|
||||||
<!-- file: ./views/hello.html -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Hello Page</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>{{.message}}</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
|
||||||
|
|
||||||
![overview screen](https://github.com/kataras/build-a-better-web-together/raw/master/overview_screen_1.png)
|
|
||||||
|
|
||||||
> Wanna re-start your app automatically when source code changes happens? Install the [rizla](https://github.com/kataras/rizla) tool and execute `rizla main.go` instead of `go run main.go`.
|
|
||||||
|
|
||||||
Table of Contents
|
|
||||||
------------
|
|
||||||
|
|
||||||
<a href ="https://iris-go.com/v8/recipe"> <img align="right" alt="Book cover" src="https://raw.githubusercontent.com/kataras/build-a-better-web-together/master/cover.jpg" width="300" /></a>
|
|
||||||
|
|
||||||
* [Why a new web framework](Why.md)
|
|
||||||
* [Features](Features.md)
|
|
||||||
* [Versioning](Versioning.md)
|
|
||||||
* [Overview](https://github.com/kataras/iris/tree/master/_examples/#overview)
|
|
||||||
* [Hello world!](https://github.com/kataras/iris/blob/master/_examples/hello-world/main.go)
|
|
||||||
* [Glimpse](https://github.com/kataras/iris/blob/master/_examples/overview/main.go)
|
|
||||||
* [Tutorial: Online Visitors](https://github.com/kataras/iris/blob/master/_examples/tutorial/online-visitors)
|
|
||||||
* [Tutorial: URL Shortener using BoltDB](https://medium.com/@kataras/a-url-shortener-service-using-go-iris-and-bolt-4182f0b00ae7)
|
|
||||||
* [Tutorial: DropzoneJS + Go: How to build a file upload form](https://hackernoon.com/how-to-build-a-file-upload-form-using-dropzonejs-and-go-8fb9f258a991)
|
|
||||||
* [Structuring](https://github.com/kataras/iris/tree/master/_examples/#structuring)
|
|
||||||
* [Bootstrapper](https://github.com/kataras/iris/blob/master/_examples/structuring/bootstrap/bootstrap)
|
|
||||||
* [MVC with Repository and Service layer Overview](https://github.com/kataras/iris/tree/master/mvc/overview)
|
|
||||||
* [Login (MVC with Single Responsibility package)](https://github.com/kataras/iris/tree/master/structuring/login-mvc-single-responsible-package)
|
|
||||||
* [Login (MVC with Datamodels, Datasource, Repository and Service layer)](https://github.com/kataras/iris/tree/master/mvc/login)
|
|
||||||
* [HTTP Listening](https://github.com/kataras/iris/tree/master/_examples/#http-listening)
|
|
||||||
* [Common, with address](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-addr/main.go)
|
|
||||||
* [UNIX socket file](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-unix/main.go)
|
|
||||||
* [TLS](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-tls/main.go)
|
|
||||||
* [Letsencrypt (Automatic Certifications)](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-letsencrypt/main.go)
|
|
||||||
* [Custom net.Listener](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-listener/main.go)
|
|
||||||
* [SO_REUSEPORT for unix systems](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-listener/unix-reuseport/main.go)
|
|
||||||
* [Omit server errors](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-addr/omit-server-errors/main.go)
|
|
||||||
* [Custom HTTP Server](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-httpserver/easy-way/main.go)
|
|
||||||
* [Custom HTTP Server (STD)](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-httpserver/std-way/main.go)
|
|
||||||
* [Multi HTTP Servers](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-httpserver/multi/main.go)
|
|
||||||
* [Graceful Shutdown](https://github.com/kataras/iris/blob/master/_examples/http-listening/graceful-shutdown/default-notifier/main.go)
|
|
||||||
* [Configuration](https://github.com/kataras/iris/tree/master/_examples/#configuration)
|
|
||||||
* [Functional](https://github.com/kataras/iris/blob/master/_examples/configuration/functional/main.go)
|
|
||||||
* [From Configuration Struct](https://github.com/kataras/iris/blob/master/_examples/configuration/from-configuration-structure/main.go)
|
|
||||||
* [Import from YAML file](https://github.com/kataras/iris/blob/master/_examples/configuration/from-yaml-file/main.go)
|
|
||||||
* [Import from TOML file](https://github.com/kataras/iris/blob/master/_examples/configuration/from-toml-file/main.go)
|
|
||||||
* [Routing](https://github.com/kataras/iris/tree/master/_examples/#routing-grouping-dynamic-path-parameters-macros-and-custom-context)
|
|
||||||
* [Overview](https://github.com/kataras/iris/blob/master/_examples/routing/overview/main.go)
|
|
||||||
* [Basic](https://github.com/kataras/iris/blob/master/_examples/routing/basic/main.go)
|
|
||||||
* [Custom HTTP Errors](https://github.com/kataras/iris/blob/master/_examples/routing/http-errors/main.go)
|
|
||||||
* [Dynamic Path](https://github.com/kataras/iris/blob/master/_examples/routing/dynamic-path/main.go)
|
|
||||||
* [Root level wildcard path](https://github.com/kataras/iris/blob/master/_examples/routing/dynamic-path/root-wildcard/main.go)
|
|
||||||
* [Reverse routing](https://github.com/kataras/iris/blob/master/_examples/routing/reverse/main.go)
|
|
||||||
* [Custom wrapper](https://github.com/kataras/iris/blob/master/_examples/routing/custom-wrapper/main.go)
|
|
||||||
* [Route State](https://github.com/kataras/iris/blob/master/_examples/routing/route-state/main.go)
|
|
||||||
* [MVC](https://github.com/kataras/iris/tree/master/_examples/#mvc)
|
|
||||||
* [Hello world](https://github.com/kataras/iris/tree/master/_examples/mvc/hello-world)
|
|
||||||
* [Session Controller](https://github.com/kataras/iris/tree/master/_examples/mvc/session-controller)
|
|
||||||
* [Overview - Plus Repository and Service layers](https://github.com/kataras/tree/tree/master/_examples/mvc/overview)
|
|
||||||
* [Login showcase - Plus Repository and Service layers](https://github.com/kataras/iris/tree/master/_examples/mvc/login)
|
|
||||||
* [Custom Context](https://github.com/kataras/iris/tree/master/_examples/routing/custom-context)
|
|
||||||
* [Method Overriding](https://github.com/kataras/iris/blob/master/_examples/routing/custom-context/method-overriding/main.go)
|
|
||||||
* [New Implementation](https://github.com/kataras/iris/blob/master/_examples/routing/custom-context/new-implementation/main.go)
|
|
||||||
* [Convert http.Handler](https://github.com/kataras/iris/tree/master/_examples/convert-handlers)
|
|
||||||
* [From func(http.ResponseWriter, *http.Request, http.HandlerFunc)](convert-handlers/negroni-like/main.go)
|
|
||||||
* [From http.Handler or http.HandlerFunc](convert-handlers/nethttp/main.go)
|
|
||||||
* [Subdomains](subdomains)
|
|
||||||
* [Single](https://github.com/kataras/iris/blob/master/_examples/subdomains/single/main.go)
|
|
||||||
* [Multi](https://github.com/kataras/iris/blob/master/_examples/subdomains/multi/main.go)
|
|
||||||
* [Wildcard](https://github.com/kataras/iris/blob/master/_examples/subdomains/wildcard/main.go)
|
|
||||||
* [WWW](https://github.com/kataras/iris/blob/master/_examples/subdomains/www/main.go)
|
|
||||||
* [View](https://github.com/kataras/iris/tree/master/_examples/#view)
|
|
||||||
* [Overview](https://github.com/kataras/iris/blob/master/_examples/view/overview/main.go)
|
|
||||||
* [Hi](https://github.com/kataras/iris/blob/master/_examples/view/template_html_0/main.go)
|
|
||||||
* [A simple Layout](https://github.com/kataras/iris/blob/master/_examples/view/template_html_1/main.go)
|
|
||||||
* [Layouts: `yield` and `render` tmpl funcs](https://github.com/kataras/iris/blob/master/_examples/view/template_html_2/main.go)
|
|
||||||
* [The `urlpath` tmpl func](https://github.com/kataras/iris/blob/master/_examples/view/template_html_3/main.go)
|
|
||||||
* [The `url` tmpl func](https://github.com/kataras/iris/blob/master/_examples/view/template_html_4/main.go)
|
|
||||||
* [Inject Data Between Handlers](https://github.com/kataras/iris/blob/master/_examples/view/context-view-data/main.go)
|
|
||||||
* [Embedding Templates Into App Executable File](https://github.com/kataras/iris/blob/master/_examples/view/embedding-templates-into-app/main.go)
|
|
||||||
* [Authentication](https://github.com/kataras/iris/tree/master/_examples/#authentication)
|
|
||||||
* [Basic Authentication](https://github.com/kataras/iris/blob/master/_examples/authentication/basicauth/main.go)
|
|
||||||
* [OAUth2](https://github.com/kataras/iris/blob/master/_examples/authentication/oauth2/main.go)
|
|
||||||
* [JWT](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/jwt/simple/main.go)
|
|
||||||
* [File Server](https://github.com/kataras/iris/tree/master/_examples/#file-server)
|
|
||||||
* [Favicon](https://github.com/kataras/iris/blob/master/_examples/file-server/favicon/main.go)
|
|
||||||
* [Basic](https://github.com/kataras/iris/blob/master/_examples/file-server/basic/main.go)
|
|
||||||
* [Embedding Files Into App Executable File](https://github.com/kataras/iris/blob/master/_examples/file-server/embedding-files-into-app/main.go)
|
|
||||||
* [Send/Force-Download Files](https://github.com/kataras/iris/blob/master/_examples/file-server/send-files/main.go)
|
|
||||||
* [Single Page Applications](https://github.com/kataras/iris/tree/master/_examples/file-server/single-page-application)
|
|
||||||
* [Single Page Application](https://github.com/kataras/iris/blob/master/_examples/file-server/single-page-application/basic/main.go)
|
|
||||||
* [Embedded Single Page Application](https://github.com/kataras/iris/blob/master/_examples/file-server/single-page-application/embedded-single-page-application/main.go)
|
|
||||||
* [Embedded Single Page Application with other routes](https://github.com/kataras/iris/blob/master/_examples/file-server/single-page-application/embedded-single-page-application-with-other-routes/main.go)
|
|
||||||
* [How to Read from *http.Request`](https://github.com/kataras/iris/tree/master/_examples/#how-to-read-from-contextrequest-httprequest)
|
|
||||||
* [Bind JSON](https://github.com/kataras/iris/blob/master/_examples/http_request/read-json/main.go)
|
|
||||||
* [Bind Form](https://github.com/kataras/iris/blob/master/_examples/http_request/read-form/main.go)
|
|
||||||
* [Upload/Read Files](https://github.com/kataras/iris/blob/master/_examples/http_request/upload-files/main.go)
|
|
||||||
* [How to Write to http.ResponseWriter](https://github.com/kataras/iris/tree/master/_examples/#how-to-write-to-contextresponsewriter-httpresponsewriter)
|
|
||||||
* [Write `valyala/quicktemplate` templates](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/quicktemplate/main.go)
|
|
||||||
* [Text, Markdown, HTML, JSON, JSONP, XML, Binary](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/write-rest/main.go)
|
|
||||||
* [Stream Writer](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/stream-writer/main.go)
|
|
||||||
* [Transactions](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/transactions/main.go)
|
|
||||||
* [Miscellaneous](https://github.com/kataras/iris/blob/master/_examples/#miscellaneous)
|
|
||||||
* [Request Logger](https://github.com/kataras/iris/blob/master/_examples/http_request/request-logger/main.go)
|
|
||||||
* [Log Requests to a file](https://github.com/kataras/iris/blob/master/_examples/http_request/request-logger/request-logger-file/main.go)
|
|
||||||
* [Localization and Internationalization](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/i18n/main.go)
|
|
||||||
* [Recovery](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/recover/main.go)
|
|
||||||
* [Profiling (pprof)](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/pprof/main.go)
|
|
||||||
* [Internal Application File Logger](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/file-logger/main.go)
|
|
||||||
* [Testing](https://github.com/kataras/iris/blob/master/_examples/testing/httptest/main_test.go)
|
|
||||||
* [Caching](https://github.com/kataras/iris/blob/master/_examples/cache/simple/main.go)
|
|
||||||
* [Yaag - API Automated Docs](https://github.com/kataras/iris/blob/master/_examples/apidoc/yaag/main.go)
|
|
||||||
* [Sessions](https://github.com/kataras/iris/blob/master/_examples/#sessions)
|
|
||||||
* [Overview](https://github.com/kataras/iris/blob/master/_examples/sessions/overview/main.go)
|
|
||||||
* [Standalone](https://github.com/kataras/iris/blob/master/_examples/sessions/standalone/main.go)
|
|
||||||
* [Secure Cookie](https://github.com/kataras/iris/blob/master/_examples/sessions/securecookie/main.go)
|
|
||||||
* [Flash Messages](https://github.com/kataras/iris/blob/master/_examples/sessions/flash-messages/main.go)
|
|
||||||
* [Database](https://github.com/kataras/iris/blob/master/_examples/sessions/database/main.go)
|
|
||||||
* [Websockets](https://github.com/kataras/iris/tree/master/_examples/#websockets)
|
|
||||||
* [Chat](https://github.com/kataras/iris/blob/master/_examples/websocket/chat/main.go)
|
|
||||||
* [Native Messages](https://github.com/kataras/iris/blob/master/_examples/websocket/native-messages/main.go)
|
|
||||||
* [Connection List](https://github.com/kataras/iris/blob/master/_examples/websocket/connectionlist/main.go)
|
|
||||||
* [TLS Enabled](https://github.com/kataras/iris/blob/master/_examples/websocket/secure/main.go)
|
|
||||||
* [Custom Raw Go Client](https://github.com/kataras/iris/blob/master/_examples/websocket/custom-go-client/main.go)
|
|
||||||
* [Experimental Handlers](https://github.com/kataras/iris/tree/master/_examples/experimental-handlers)
|
|
||||||
* [Casbin wrapper](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/casbin/wrapper/main.go)
|
|
||||||
* [Casbin middleware](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/casbin/middleware/main.go)
|
|
||||||
* [Cloudwatch](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/cloudwatch/simple/main.go)
|
|
||||||
* [CORS](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/cors/simple/main.go)
|
|
||||||
* [JWT](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/jwt/main.go)
|
|
||||||
* [Newrelic](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/newrelic/simple/main.go)
|
|
||||||
* [Prometheus](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/prometheus/simple/main.go)
|
|
||||||
* [Secure](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/secure/simple/main.go)
|
|
||||||
* [Tollboothic](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/tollboothic/limit-handler/main.go)
|
|
39
Routing-error-handlers.md
Normal file
39
Routing-error-handlers.md
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# Error handlers
|
||||||
|
|
||||||
|
You can define your own handlers when a specific http error code occurs.
|
||||||
|
|
||||||
|
> Error codes are the http status codes that are bigger than or equal to 400, like 404 not found and 500 internal server.
|
||||||
|
|
||||||
|
Example code:
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/kataras/iris"
|
||||||
|
|
||||||
|
func main(){
|
||||||
|
app := iris.New()
|
||||||
|
app.OnErrorCode(iris.StatusNotFound, notFound)
|
||||||
|
app.OnErrorCode(iris.StatusInternalServerError, internalServerError)
|
||||||
|
// to register a handler for all "error"
|
||||||
|
// status codes(kataras/iris/context.StatusCodeNotSuccessful)
|
||||||
|
// defaults to < 200 || >= 400:
|
||||||
|
// app.OnAnyErrorCode(handler)
|
||||||
|
app.Get("/", index)
|
||||||
|
app.Run(iris.Addr(":8080"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func notFound(ctx iris.Context) {
|
||||||
|
// when 404 then render the template
|
||||||
|
// $views_dir/errors/404.html
|
||||||
|
ctx.View("errors/404.html")
|
||||||
|
}
|
||||||
|
|
||||||
|
func internalServerError(ctx iris.Context) {
|
||||||
|
ctx.WriteString("Oups something went wrong, try again")
|
||||||
|
}
|
||||||
|
|
||||||
|
func index(ctx context.Context) {
|
||||||
|
ctx.View("index.html")
|
||||||
|
}
|
||||||
|
```
|
141
Routing-middleware.md
Normal file
141
Routing-middleware.md
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
# Middleware
|
||||||
|
|
||||||
|
When we talk about Middleware in Iris we're talking about running code before and/or after our main handler code in a HTTP request lifecycle. For example, logging middleware might write the incoming request details to a log, then call the handler code, before writing details about the response to the log. One of the cool things about middleware is that these units are extremely flexible and reusable.
|
||||||
|
|
||||||
|
A middleware is just a **Handler** form of `func(ctx iris.Context)`, the middleware is being executed when the previous middleware calls the `ctx.Next()`, this can be used for authentication, i.e: if request authenticated then call `ctx.Next()` to process with the rest of the chain of handlers in the request otherwise fire an error response.
|
||||||
|
|
||||||
|
## Writing a middleware
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/kataras/iris"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := iris.New()
|
||||||
|
// or app.Use(before) and app.Done(after).
|
||||||
|
app.Get("/", before, mainHandler, after)
|
||||||
|
app.Run(iris.Addr(":8080"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func before(ctx iris.Context) {
|
||||||
|
shareInformation := "this is a sharable information between handlers"
|
||||||
|
|
||||||
|
requestPath := ctx.Path()
|
||||||
|
println("Before the mainHandler: " + requestPath)
|
||||||
|
|
||||||
|
ctx.Values().Set("info", shareInformation)
|
||||||
|
ctx.Next() // execute the next handler, in this case the main one.
|
||||||
|
}
|
||||||
|
|
||||||
|
func after(ctx iris.Context) {
|
||||||
|
println("After the mainHandler")
|
||||||
|
}
|
||||||
|
|
||||||
|
func mainHandler(ctx iris.Context) {
|
||||||
|
println("Inside mainHandler")
|
||||||
|
|
||||||
|
// take the info from the "before" handler.
|
||||||
|
info := ctx.Values().GetString("info")
|
||||||
|
|
||||||
|
// write something to the client as a response.
|
||||||
|
ctx.HTML("<h1>Response</h1>")
|
||||||
|
ctx.HTML("<br/> Info: " + info)
|
||||||
|
|
||||||
|
ctx.Next() // execute the "after".
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ go run main.go # and navigate to the http://localhost:8080
|
||||||
|
Now listening on: http://localhost:8080
|
||||||
|
Application started. Press CTRL+C to shut down.
|
||||||
|
Before the mainHandler: /
|
||||||
|
Inside mainHandler
|
||||||
|
After the mainHandler
|
||||||
|
```
|
||||||
|
|
||||||
|
### Globally
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/kataras/iris"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := iris.New()
|
||||||
|
|
||||||
|
// register our routes.
|
||||||
|
app.Get("/", indexHandler)
|
||||||
|
app.Get("/contact", contactHandler)
|
||||||
|
|
||||||
|
// Order of those calls doesn't matter, `UseGlobal` and `DoneGlobal`
|
||||||
|
// are applied to existing routes and future routes.
|
||||||
|
//
|
||||||
|
// Remember: the `Use` and `Done` are applied to the current party's and its children,
|
||||||
|
// so if we used the `app.Use/Don`e before the routes registration
|
||||||
|
// it would work like UseGlobal/DoneGlobal in this case, because the `app` is the root party.
|
||||||
|
//
|
||||||
|
// See `app.Party/PartyFunc` for more.
|
||||||
|
app.UseGlobal(before)
|
||||||
|
app.DoneGlobal(after)
|
||||||
|
|
||||||
|
app.Run(iris.Addr(":8080"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func before(ctx iris.Context) {
|
||||||
|
// [...]
|
||||||
|
}
|
||||||
|
|
||||||
|
func after(ctx iris.Context) {
|
||||||
|
// [...]
|
||||||
|
}
|
||||||
|
|
||||||
|
func indexHandler(ctx iris.Context) {
|
||||||
|
// write something to the client as a response.
|
||||||
|
ctx.HTML("<h1>Index</h1>")
|
||||||
|
|
||||||
|
ctx.Next() // execute the "after" handler registered via `Done`.
|
||||||
|
}
|
||||||
|
|
||||||
|
func contactHandler(ctx iris.Context) {
|
||||||
|
// write something to the client as a response.
|
||||||
|
ctx.HTML("<h1>Contact</h1>")
|
||||||
|
|
||||||
|
ctx.Next() // execute the "after" handler registered via `Done`.
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Any third-party middleware that written for `net/http` is automatic compatible with Iris using the `iris.FromStd(aThirdPartyMiddleware)`. Remember, `ctx.ResponseWriter()` and `ctx.Request()` returns the same `net/http` input arguments for an `http.Handler`. See [here](https://github.com/kataras/iris/tree/master/_examples/convert-handlers) for an example.
|
||||||
|
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Here is a list of some handlers made specifically for Iris:
|
||||||
|
|
||||||
|
## Built-in
|
||||||
|
|
||||||
|
| Middleware | Example |
|
||||||
|
| -----------|-------------|
|
||||||
|
| [basic authentication](basicauth) | [iris/_examples/authentication/basicauth](https://github.com/kataras/iris/tree/master/_examples/authentication/basicauth) |
|
||||||
|
| [Google reCAPTCHA](recaptcha) | [iris/_examples/miscellaneous/recaptcha](https://github.com/kataras/iris/tree/master/_examples/miscellaneous/recaptcha) |
|
||||||
|
| [localization and internationalization](i18n) | [iris/_examples/miscellaneous/i81n](https://github.com/kataras/iris/tree/master/_examples/miscellaneous/i18n) |
|
||||||
|
| [request logger](logger) | [iris/_examples/http_request/request-logger](https://github.com/kataras/iris/tree/master/_examples/http_request/request-logger) |
|
||||||
|
| [profiling (pprof)](pprof) | [iris/_examples/miscellaneous/pprof](https://github.com/kataras/iris/tree/master/_examples/miscellaneous/pprof) |
|
||||||
|
| [recovery](recover) | [iris/_examples/miscellaneous/recover](https://github.com/kataras/iris/tree/master/_examples/miscellaneous/recover) |
|
||||||
|
|
||||||
|
## Community made
|
||||||
|
|
||||||
|
Most of the experimental handlers are ported to work with _iris_'s handler form, from third-party sources.
|
||||||
|
|
||||||
|
| Middleware | Description | Example |
|
||||||
|
| -----------|--------|-------------|
|
||||||
|
| [jwt](https://github.com/iris-contrib/middleware/tree/master/jwt) | Middleware checks for a JWT on the `Authorization` header on incoming requests and decodes it. | [iris-contrib/middleware/jwt/_example](https://github.com/iris-contrib/middleware/tree/master/jwt/_example) |
|
||||||
|
| [cors](https://github.com/iris-contrib/middleware/tree/master/cors) | HTTP Access Control. | [iris-contrib/middleware/cors/_example](https://github.com/iris-contrib/middleware/tree/master/cors/_example) |
|
||||||
|
| [secure](https://github.com/iris-contrib/middleware/tree/master/secure) | Middleware that implements a few quick security wins. | [iris-contrib/middleware/secure/_example](https://github.com/iris-contrib/middleware/tree/master/secure/_example/main.go) |
|
||||||
|
| [tollbooth](https://github.com/iris-contrib/middleware/tree/master/tollboothic) | Generic middleware to rate-limit HTTP requests. | [iris-contrib/middleware/tollbooth/_examples/limit-handler](https://github.com/iris-contrib/middleware/tree/master/tollbooth/_examples/limit-handler) |
|
||||||
|
| [cloudwatch](https://github.com/iris-contrib/middleware/tree/master/cloudwatch) | AWS cloudwatch metrics middleware. |[iris-contrib/middleware/cloudwatch/_example](https://github.com/iris-contrib/middleware/tree/master/cloudwatch/_example) |
|
||||||
|
| [new relic](https://github.com/iris-contrib/middleware/tree/master/newrelic) | Official [New Relic Go Agent](https://github.com/newrelic/go-agent). | [iris-contrib/middleware/newrelic/_example](https://github.com/iris-contrib/middleware/tree/master/newrelic/_example) |
|
||||||
|
| [prometheus](https://github.com/iris-contrib/middleware/tree/master/prometheus)| Easily create metrics endpoint for the [prometheus](http://prometheus.io) instrumentation tool | [iris-contrib/middleware/prometheus/_example](https://github.com/iris-contrib/middleware/tree/master/prometheus/_example) |
|
||||||
|
| [casbin](https://github.com/iris-contrib/middleware/tree/master/casbin)| An authorization library that supports access control models like ACL, RBAC, ABAC | [iris-contrib/middleware/casbin/_examples](https://github.com/iris-contrib/middleware/tree/master/casbin/_examples) |
|
||||||
|
| [raven](https://github.com/iris-contrib/middleware/tree/master/raven)| Sentry client in Go | [iris-contrib/middleware/raven/_example](https://github.com/iris-contrib/middleware/blob/master/raven/_example/main.go) |
|
||||||
|
| [csrf](https://github.com/iris-contrib/middleware/tree/master/csrf)| Cross-Site Request Forgery Protection | [iris-contrib/middleware/csrf/_example](https://github.com/iris-contrib/middleware/blob/master/csrf/_example/main.go) |
|
159
Routing-path-parameter-types.md
Normal file
159
Routing-path-parameter-types.md
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
Iris has the easiest and the most powerful routing process you have ever met.
|
||||||
|
|
||||||
|
Iris has its own interpeter for route's path syntax, parsing and evaluation (yes, like a programming language!).
|
||||||
|
|
||||||
|
|
||||||
|
It's fast, how? It calculates its needs and if not any special regexp needed then it just
|
||||||
|
registers the route with the low-level path syntax,
|
||||||
|
otherwise it pre-compiles the regexp and adds the necessary middleware(s). That means that you have zero performance cost compared to other routers or web frameworks.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
A path parameter's name should contain only alphabetical letters or digits. Symbols like '_' are NOT allowed.
|
||||||
|
|
||||||
|
Do not confuse `ctx.Params()` with `ctx.Values()`.
|
||||||
|
|
||||||
|
* Path parameter's values can be retrieved from `ctx.Params()`.
|
||||||
|
* Context's local storage that can be used to communicate between handlers and middleware(s) can be stored to `ctx.Values()`.
|
||||||
|
|
||||||
|
The built-in available parameter types can be found at the following table.
|
||||||
|
|
||||||
|
| Param Type | Go Type | Validation | Retrieve Helper |
|
||||||
|
| -----------------|------|-------------|------|
|
||||||
|
| `:string` | string | anything (single path segment) | `Params().Get` |
|
||||||
|
| `:int` | int | -9223372036854775808 to 9223372036854775807 (x64) or -2147483648 to 2147483647 (x32), depends on the host arch | `Params().GetInt` |
|
||||||
|
| `:int8` | int8 | -128 to 127 | `Params().GetInt8` |
|
||||||
|
| `:int16` | int16 | -32768 to 32767 | `Params().GetInt16` |
|
||||||
|
| `:int32` | int32 | -2147483648 to 2147483647 | `Params().GetInt32` |
|
||||||
|
| `:int64` | int64 | -9223372036854775808 to 9223372036854775807 | `Params().GetInt64` |
|
||||||
|
| `:uint` | uint | 0 to 18446744073709551615 (x64) or 0 to 4294967295 (x32), depends on the host arch | `Params().GetUint` |
|
||||||
|
| `:uint8` | uint8 | 0 to 255 | `Params().GetUint8` |
|
||||||
|
| `:uint16` | uint16 | 0 to 65535 | `Params().GetUint16` |
|
||||||
|
| `:uint32` | uint32 | 0 to 4294967295 | `Params().GetUint32` |
|
||||||
|
| `:uint64` | uint64 | 0 to 18446744073709551615 | `Params().GetUint64` |
|
||||||
|
| `:bool` | bool | "1" or "t" or "T" or "TRUE" or "true" or "True" or "0" or "f" or "F" or "FALSE" or "false" or "False" | `Params().GetBool` |
|
||||||
|
| `:alphabetical` | string | lowercase or uppercase letters | `Params().Get` |
|
||||||
|
| `:file` | string | lowercase or uppercase letters, numbers, underscore (_), dash (-), point (.) and no spaces or other special characters that are not valid for filenames | `Params().Get` |
|
||||||
|
| `:path` | string | anything, can be separated by slashes (path segments) but should be the last part of the route path | `Params().Get` |
|
||||||
|
|
||||||
|
**Usage**:
|
||||||
|
|
||||||
|
```go
|
||||||
|
app.Get("/users/{id:uint64}", func(ctx iris.Context){
|
||||||
|
id := ctx.Params().GetUint64Default("id", 0)
|
||||||
|
// [...]
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
| Built-in Func | Param Types |
|
||||||
|
| -----------|---------------|
|
||||||
|
| `regexp`(expr string) | :string |
|
||||||
|
| `prefix`(prefix string) | :string |
|
||||||
|
| `suffix`(suffix string) | :string |
|
||||||
|
| `contains`(s string) | :string |
|
||||||
|
| `min`(minValue int or int8 or int16 or int32 or int64 or uint8 or uint16 or uint32 or uint64 or float32 or float64) | :string(char length), :int, :int8, :int16, :int32, :int64, :uint, :uint8, :uint16, :uint32, :uint64 |
|
||||||
|
| `max`(maxValue int or int8 or int16 or int32 or int64 or uint8 or uint16 or uint32 or uint64 or float32 or float64) | :string(char length), :int, :int8, :int16, :int32, :int64, :uint, :uint8, :uint16, :uint32, :uint64 |
|
||||||
|
| `range`(minValue, maxValue int or int8 or int16 or int32 or int64 or uint8 or uint16 or uint32 or uint64 or float32 or float64) | :int, :int8, :int16, :int32, :int64, :uint, :uint8, :uint16, :uint32, :uint64 |
|
||||||
|
|
||||||
|
**Usage**:
|
||||||
|
|
||||||
|
```go
|
||||||
|
app.Get("/profile/{name:alphabetical max(255)}", func(ctx iris.Context){
|
||||||
|
name := ctx.Params().Get("name")
|
||||||
|
// len(name) <=255 otherwise this route will fire 404 Not Found
|
||||||
|
// and this handler will not be executed at all.
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Do It Yourself**:
|
||||||
|
|
||||||
|
The `RegisterFunc` can accept any function that returns a `func(paramValue string) bool`.
|
||||||
|
Or just a `func(string) bool`.
|
||||||
|
If the validation fails then it will fire `404` or whatever status code the `else` keyword has.
|
||||||
|
|
||||||
|
```go
|
||||||
|
latLonExpr := "^-?[0-9]{1,3}(?:\\.[0-9]{1,10})?$"
|
||||||
|
latLonRegex, _ := regexp.Compile(latLonExpr)
|
||||||
|
|
||||||
|
// Register your custom argument-less macro function to the :string param type.
|
||||||
|
// MatchString is a type of func(string) bool, so we use it as it is.
|
||||||
|
app.Macros().Get("string").RegisterFunc("coordinate", latLonRegex.MatchString)
|
||||||
|
|
||||||
|
app.Get("/coordinates/{lat:string coordinate()}/{lon:string coordinate()}", func(ctx iris.Context) {
|
||||||
|
ctx.Writef("Lat: %s | Lon: %s", ctx.Params().Get("lat"), ctx.Params().Get("lon"))
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Register your custom macro function which accepts two int arguments.
|
||||||
|
|
||||||
|
```go
|
||||||
|
|
||||||
|
app.Macros().Get("string").RegisterFunc("range", func(minLength, maxLength int) func(string) bool {
|
||||||
|
return func(paramValue string) bool {
|
||||||
|
return len(paramValue) >= minLength && len(paramValue) <= maxLength
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
app.Get("/limitchar/{name:string range(1,200) else 400}", func(ctx iris.Context) {
|
||||||
|
name := ctx.Params().Get("name")
|
||||||
|
ctx.Writef(`Hello %s | the name should be between 1 and 200 characters length
|
||||||
|
otherwise this handler will not be executed`, name)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
Register your custom macro function which accepts a slice of strings `[...,...]`.
|
||||||
|
|
||||||
|
```go
|
||||||
|
app.Macros().Get("string").RegisterFunc("has", func(validNames []string) func(string) bool {
|
||||||
|
return func(paramValue string) bool {
|
||||||
|
for _, validName := range validNames {
|
||||||
|
if validName == paramValue {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
app.Get("/static_validation/{name:string has([kataras,gerasimos,maropoulos])}", func(ctx iris.Context) {
|
||||||
|
name := ctx.Params().Get("name")
|
||||||
|
ctx.Writef(`Hello %s | the name should be "kataras" or "gerasimos" or "maropoulos"
|
||||||
|
otherwise this handler will not be executed`, name)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example Code**:
|
||||||
|
|
||||||
|
```go
|
||||||
|
func main() {
|
||||||
|
app := iris.Default()
|
||||||
|
|
||||||
|
// This handler will match /user/john but will not match neither /user/ or /user.
|
||||||
|
app.Get("/user/{name}", func(ctx iris.Context) {
|
||||||
|
name := ctx.Params().Get("name")
|
||||||
|
ctx.Writef("Hello %s", name)
|
||||||
|
})
|
||||||
|
|
||||||
|
// This handler will match /users/42
|
||||||
|
// but will not match /users/-1 because uint should be bigger than zero
|
||||||
|
// neither /users or /users/.
|
||||||
|
app.Get("/users/{id:uint64}", func(ctx iris.Context) {
|
||||||
|
id := ctx.Params().GetUint64Default("id", 0)
|
||||||
|
ctx.Writef("User with ID: %d", id)
|
||||||
|
})
|
||||||
|
|
||||||
|
// However, this one will match /user/john/send and also /user/john/everything/else/here
|
||||||
|
// but will not match /user/john neither /user/john/.
|
||||||
|
app.Post("/user/{name:string}/{action:path}", func(ctx iris.Context) {
|
||||||
|
name := ctx.Params().Get("name")
|
||||||
|
action := ctx.Params().Get("action")
|
||||||
|
message := name + " is " + action
|
||||||
|
ctx.WriteString(message)
|
||||||
|
})
|
||||||
|
|
||||||
|
app.Run(iris.Addr(":8080"))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
> When parameter type is missing then defaults to `string`, therefore `{name:string}` and `{name}` do the same exactly thing.
|
57
Routing-reverse-lookups.md
Normal file
57
Routing-reverse-lookups.md
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
# Reverse Lookups
|
||||||
|
|
||||||
|
As mentioned in the [[Routing]] chapter, Iris provides several handler registration methods, each of which returns a [`Route`](https://godoc.org/github.com/kataras/iris/core/router#Route) instance.
|
||||||
|
|
||||||
|
## Route naming
|
||||||
|
|
||||||
|
Route naming is easy, since we just call the returned `*Route` with a `Name` field to define a name:
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/kataras/iris"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := iris.New()
|
||||||
|
// define a function
|
||||||
|
h := func(ctx iris.Context) {
|
||||||
|
ctx.HTML("<b>Hi</b1>")
|
||||||
|
}
|
||||||
|
|
||||||
|
// handler registration and naming
|
||||||
|
home := app.Get("/", h)
|
||||||
|
home.Name = "home"
|
||||||
|
// or
|
||||||
|
app.Get("/about", h).Name = "about"
|
||||||
|
app.Get("/page/{id}", h).Name = "page"
|
||||||
|
|
||||||
|
app.Run(iris.Addr(":8080"))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Route reversing AKA generating URLs from the route name
|
||||||
|
|
||||||
|
When we register the handlers for a specific path, we get the ability to create URLs based on the structured data we pass to Iris. In the example above, we've named three routers, one of which even takes parameters. If we're using the default `html/template` view engine, we can use a simple action to reverse the routes (and generae actual URLs):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
Home: {{ urlpath "home" }}
|
||||||
|
About: {{ urlpath "about" }}
|
||||||
|
Page 17: {{ urlpath "page" "17" }}
|
||||||
|
```
|
||||||
|
|
||||||
|
Above code would generate the following output:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
Home: http://localhost:8080/
|
||||||
|
About: http://localhost:8080/about
|
||||||
|
Page 17: http://localhost:8080/page/17
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using route names in code
|
||||||
|
|
||||||
|
We can use the following methods/functions to work with named routes (and their parameters):
|
||||||
|
|
||||||
|
* [`GetRoutes`](https://godoc.org/github.com/kataras/iris/core/router#APIBuilder.GetRoutes) function to get all registered routes
|
||||||
|
* [`GetRoute(routeName string)`](https://godoc.org/github.com/kataras/iris/core/router#APIBuilder.GetRoute) method to retrieve a route by name
|
||||||
|
* [`URL(routeName string, paramValues ...interface{})`](https://godoc.org/github.com/kataras/iris/core/router#RoutePathReverser.URL) method to generate url string based on supplied parameters
|
||||||
|
* [`Path(routeName string, paramValues ...interface{}`](https://godoc.org/github.com/kataras/iris/core/router#RoutePathReverser.Path) method to generate just the path (without host and protocol) portion of the URL based on provided values
|
106
Routing-wrap-the-router.md
Normal file
106
Routing-wrap-the-router.md
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
# Wrapping the Router
|
||||||
|
|
||||||
|
You may never need this one but it's here in case.
|
||||||
|
|
||||||
|
There are times that you may need to override or decide whether the Router will be executed on an incoming request. If you've any previous experience with the `net/http` and other web frameworks this function will be familiar with you (it has the form of a net/http middleware, but instead of accepting the next handler it accepts the Router as a function to be executed or not).
|
||||||
|
|
||||||
|
```go
|
||||||
|
// WrapperFunc is used as an expected input parameter signature
|
||||||
|
// for the WrapRouter. It's a "low-level" signature which is compatible
|
||||||
|
// with the net/http.
|
||||||
|
// It's being used to run or no run the router based on a custom logic.
|
||||||
|
type WrapperFunc func(w http.ResponseWriter, r *http.Request, firstNextIsTheRouter http.HandlerFunc)
|
||||||
|
|
||||||
|
// WrapRouter adds a wrapper on the top of the main router.
|
||||||
|
// Usually it's useful for third-party middleware
|
||||||
|
// when need to wrap the entire application with a middleware like CORS.
|
||||||
|
//
|
||||||
|
// Developers can add more than one wrappers,
|
||||||
|
// those wrappers' execution comes from last to first.
|
||||||
|
// That means that the second wrapper will wrap the first, and so on.
|
||||||
|
//
|
||||||
|
// Before build.
|
||||||
|
func WrapRouter(wrapperFunc WrapperFunc)
|
||||||
|
```
|
||||||
|
|
||||||
|
The Router searches for its routes based on the `Subdomain`, `HTTP Method` and its dynamic `Path`. A Router Wrapper can override that behavior and execute custom code.
|
||||||
|
|
||||||
|
In this example you'll just see one use case of .WrapRouter.
|
||||||
|
You can use the .WrapRouter to add custom logic when or when not the router should
|
||||||
|
be executed in order to execute the registered routes' handlers.
|
||||||
|
This is just for the proof of concept, you can skip this tutorial.
|
||||||
|
|
||||||
|
Example Code:
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/kataras/iris"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newApp() *iris.Application {
|
||||||
|
app := iris.New()
|
||||||
|
|
||||||
|
app.OnErrorCode(iris.StatusNotFound, func(ctx iris.Context) {
|
||||||
|
ctx.HTML("<b>Resource Not found</b>")
|
||||||
|
})
|
||||||
|
|
||||||
|
app.Get("/profile/{username}", func(ctx iris.Context) {
|
||||||
|
ctx.Writef("Hello %s", ctx.Params().Get("username"))
|
||||||
|
})
|
||||||
|
|
||||||
|
app.HandleDir("/", "./public")
|
||||||
|
|
||||||
|
myOtherHandler := func(ctx iris.Context) {
|
||||||
|
ctx.Writef("inside a handler which is fired manually by our custom router wrapper")
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrap the router with a native net/http handler.
|
||||||
|
// if url does not contain any "." (i.e: .css, .js...)
|
||||||
|
// (depends on the app , you may need to add more file-server exceptions),
|
||||||
|
// then the handler will execute the router that is responsible for the
|
||||||
|
// registered routes (look "/" and "/profile/{username}")
|
||||||
|
// if not then it will serve the files based on the root "/" path.
|
||||||
|
app.WrapRouter(func(w http.ResponseWriter, r *http.Request, router http.HandlerFunc) {
|
||||||
|
path := r.URL.Path
|
||||||
|
|
||||||
|
if strings.HasPrefix(path, "/other") {
|
||||||
|
// acquire and release a context in order to use it to execute
|
||||||
|
// our custom handler
|
||||||
|
// remember: we use net/http.Handler because here
|
||||||
|
// we are in the "low-level", before the router itself.
|
||||||
|
ctx := app.ContextPool.Acquire(w, r)
|
||||||
|
myOtherHandler(ctx)
|
||||||
|
app.ContextPool.Release(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// else continue serving routes as usual.
|
||||||
|
router.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
|
||||||
|
return app
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
app := newApp()
|
||||||
|
|
||||||
|
// http://localhost:8080
|
||||||
|
// http://localhost:8080/index.html
|
||||||
|
// http://localhost:8080/app.js
|
||||||
|
// http://localhost:8080/css/main.css
|
||||||
|
// http://localhost:8080/profile/anyusername
|
||||||
|
// http://localhost:8080/other/random
|
||||||
|
app.Run(iris.Addr(":8080"))
|
||||||
|
|
||||||
|
// Note: In this example we just saw one use case,
|
||||||
|
// you may want to .WrapRouter or .Downgrade in order to bypass the iris' default router, i.e:
|
||||||
|
// you can use that method to setup custom proxies too.
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
There is not much to say here, it's just a function wrapper which accepts the native response writer and request and the next handler which is the Iris' Router itself, it's being or not executed whether is called or not, **it's a middleware for the whole Router**.
|
130
Routing.md
Normal file
130
Routing.md
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
## The Handler type
|
||||||
|
|
||||||
|
A Handler, as the name implies, handle requests.
|
||||||
|
|
||||||
|
A Handler responds to an HTTP request.
|
||||||
|
It writes reply headers and data to the
|
||||||
|
Context.ResponseWriter() and then return.
|
||||||
|
Returning signals that the request is finished;
|
||||||
|
it is not valid to use the Context after or
|
||||||
|
concurrently with the completion of the Handler call.
|
||||||
|
|
||||||
|
Depending on the HTTP client software, HTTP protocol version,
|
||||||
|
and any intermediaries between the client and the iris server,
|
||||||
|
it may not be possible to read from the
|
||||||
|
Context.Request().Body after writing to the context.ResponseWriter().
|
||||||
|
Cautious handlers should read the Context.Request().Body first, and then reply.
|
||||||
|
|
||||||
|
Except for reading the body, handlers should not modify the provided Context.
|
||||||
|
|
||||||
|
If Handler panics, the server (the caller of Handler) assumes that
|
||||||
|
the effect of the panic was isolated to the active request.
|
||||||
|
It recovers the panic, logs a stack trace to the server error log
|
||||||
|
and hangs up the connection.
|
||||||
|
|
||||||
|
```go
|
||||||
|
type Handler func(iris.Context)
|
||||||
|
```
|
||||||
|
|
||||||
|
Once the handler is registered, we can use the returned [`Route`](https://godoc.org/github.com/kataras/iris/core/router#Route) instance to give a name to the handler registration for easier debugging or match relative paths in views. For more information, checkout the [[Reverse lookups|Routing-reverse-lookups]] section.
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
All HTTP methods are supported, developers can also register handlers on the same path with different methods.
|
||||||
|
|
||||||
|
The first parameter is the HTTP Method,
|
||||||
|
second parameter is the request path of the route,
|
||||||
|
third variadic parameter should contains one or more iris.Handler executed
|
||||||
|
by the registered order when a user requests for that specific resouce path from the server.
|
||||||
|
|
||||||
|
Example code:
|
||||||
|
|
||||||
|
```go
|
||||||
|
app := iris.New()
|
||||||
|
|
||||||
|
app.Handle("GET", "/contact", func(ctx iris.Context) {
|
||||||
|
ctx.HTML("<h1> Hello from /contact </h1>")
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
In order to make things easier for the end-developer, iris provides method helpers for all HTTP Methods.
|
||||||
|
The first parameter is the request path of the route,
|
||||||
|
second variadic parameter should contains one or more iris.Handler executed
|
||||||
|
by the registered order when a user requests for that specific resouce path from the server.
|
||||||
|
|
||||||
|
Example code:
|
||||||
|
|
||||||
|
```go
|
||||||
|
app := iris.New()
|
||||||
|
|
||||||
|
// Method: "GET"
|
||||||
|
app.Get("/", handler)
|
||||||
|
|
||||||
|
// Method: "POST"
|
||||||
|
app.Post("/", handler)
|
||||||
|
|
||||||
|
// Method: "PUT"
|
||||||
|
app.Put("/", handler)
|
||||||
|
|
||||||
|
// Method: "DELETE"
|
||||||
|
app.Delete("/", handler)
|
||||||
|
|
||||||
|
// Method: "OPTIONS"
|
||||||
|
app.Options("/", handler)
|
||||||
|
|
||||||
|
// Method: "TRACE"
|
||||||
|
app.Trace("/", handler)
|
||||||
|
|
||||||
|
// Method: "CONNECT"
|
||||||
|
app.Connect("/", handler)
|
||||||
|
|
||||||
|
// Method: "HEAD"
|
||||||
|
app.Head("/", handler)
|
||||||
|
|
||||||
|
// Method: "PATCH"
|
||||||
|
app.Patch("/", handler)
|
||||||
|
|
||||||
|
// register the route for all HTTP Methods
|
||||||
|
app.Any("/", handler)
|
||||||
|
|
||||||
|
func handler(ctx iris.Context){
|
||||||
|
ctx.Writef("Hello from method: %s and path: %s\n", ctx.Method(), ctx.Path())
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Grouping Routes
|
||||||
|
|
||||||
|
A set of routes that are being groupped by path prefix can (optionally) share the same middleware handlers and template layout.
|
||||||
|
A group can have a nested group too.
|
||||||
|
|
||||||
|
`.Party` is being used to group routes, developers can declare an unlimited number of (nested) groups.
|
||||||
|
|
||||||
|
Example code:
|
||||||
|
|
||||||
|
```go
|
||||||
|
app := iris.New()
|
||||||
|
|
||||||
|
users := app.Party("/users", myAuthMiddlewareHandler)
|
||||||
|
|
||||||
|
// http://localhost:8080/users/42/profile
|
||||||
|
users.Get("/{id:uint64}/profile", userProfileHandler)
|
||||||
|
// http://localhost:8080/users/messages/1
|
||||||
|
users.Get("/messages/{id:uint64}", userMessageHandler)
|
||||||
|
```
|
||||||
|
|
||||||
|
The same could be also written using the `PartyFunc` method which accepts the child router(the Party).
|
||||||
|
|
||||||
|
```go
|
||||||
|
app := iris.New()
|
||||||
|
|
||||||
|
app.PartyFunc("/users", func(users iris.Party) {
|
||||||
|
users.Use(myAuthMiddlewareHandler)
|
||||||
|
|
||||||
|
// http://localhost:8080/users/42/profile
|
||||||
|
users.Get("/{id:uint64}/profile", userProfileHandler)
|
||||||
|
// http://localhost:8080/users/messages/1
|
||||||
|
users.Get("/messages/{id:uint64}", userMessageHandler)
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
You may wonder what the `{id:uint64}` is. It's a (typed) dynamic path parameter, learn more by reading the [[Path Parameter Types|Routing-path-parameter-types]].
|
19
Support.md
Normal file
19
Support.md
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
Have you ever be in a position of waiting weeks or months for someone to respond to a github issue of yours?
|
||||||
|
If you choose Iris for your main backend development you will never be treated like a ghost again.
|
||||||
|
|
||||||
|
Iris is one of the few github public repositories that offers real support to individuals and collectivities, including companies.
|
||||||
|
Unbeatable free support for the last three years and that is just the beginning of our journey.
|
||||||
|
|
||||||
|
In these difficult and restless days we stand beside you. We do not judge bad english writing.
|
||||||
|
We are here for you, no matter who you are.
|
||||||
|
|
||||||
|
Navigate through the Iris github [repository](https://github.com/kataras/iris) to see by yourself the features and the hard work that we putted to improve how the internet is built.
|
||||||
|
|
||||||
|
### Read the latest and greatest features and get migration help
|
||||||
|
* [HISTORY](https://github.com/kataras/iris/blob/master/HISTORY.md) file is your best friend, it contains the changelog, information about the latest features and changes to the framework.
|
||||||
|
|
||||||
|
### Did you happen to find a bug?
|
||||||
|
* Post it at github issues. [Report a bug](https://github.com/kataras/iris/issues).
|
||||||
|
|
||||||
|
### Communication
|
||||||
|
* Do you have any questions or need to speak with someone experienced enough to solve a problem at real-time? Join us to the [Community Chat](https://chat.iris-go.com).
|
|
@ -1,9 +0,0 @@
|
||||||
# Versioning
|
|
||||||
|
|
||||||
Current: [v8.5.7](https://github.com/kataras/iris/blob/master/HISTORY.md#tu-07-november-2017--v857)
|
|
||||||
|
|
||||||
Read more about Semantic Versioning 2.0.0
|
|
||||||
|
|
||||||
* [semver.org](http://semver.org/)
|
|
||||||
* [en.wikipedia.org/wiki/Software/_versioning](https://en.wikipedia.org/wiki/Software_versioning)
|
|
||||||
* [wiki.debian.org/UpstreamGuide/#Releases_and_Versions](https://wiki.debian.org/UpstreamGuide#Releases_and_Versions)
|
|
79
Why.md
79
Why.md
|
@ -1,79 +0,0 @@
|
||||||
# Why
|
|
||||||
|
|
||||||
Go is a great technology stack for building scalable, web-based, back-end systems for web
|
|
||||||
applications.
|
|
||||||
|
|
||||||
When you think about building web applications and web APIs, or simply building HTTP servers in Go, does your mind go to the standard net/http package?
|
|
||||||
Then you have to deal with some common situations like dynamic routing (a.k.a parameterized), security and authentication, real-time communication and many other issues that net/http doesn't solve.
|
|
||||||
|
|
||||||
The net/http package is not complete enough to quickly build well-designed back-end web systems. When you realize this, you might be thinking along these lines:
|
|
||||||
|
|
||||||
- Ok, the net/http package doesn't suit me, but there are so many frameworks, which one will work for me?!
|
|
||||||
- Each one of them tells me that it is the best. I don't know what to do!
|
|
||||||
|
|
||||||
## The truth
|
|
||||||
|
|
||||||
I did some deep research and benchmarks with 'wrk' and 'ab' in order to choose which framework would suit me and my new project. The results, sadly, were really disappointing to me.
|
|
||||||
|
|
||||||
I started wondering if golang wasn't as fast on the web as I had read... but, before I let Golang go and continued to develop with nodejs, I told myself:
|
|
||||||
|
|
||||||
> '**Makis, don't lose hope, give at least a chance to Golang. Try to build something totally new without basing it off the "slow" code you saw earlier; learn the secrets of this language and make *others* follow your steps!**'.
|
|
||||||
|
|
||||||
These are the words I told myself that day [**13 March 2016**].
|
|
||||||
|
|
||||||
The same day, later the night, I was reading a book about Greek mythology. I saw an ancient goddess' name and was inspired immediately to give a name to this new web framework (which I had already started writing) - **Iris**.
|
|
||||||
|
|
||||||
**Two months later**, I'm writing this intro.
|
|
||||||
|
|
||||||
I'm still here [because Iris has succeed in being the fastest go web framework](https://github.com/kataras/iris#benchmarks)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment36.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment34.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment35.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment30.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment31.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment32.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment33.png)
|
|
||||||
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment29.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment26.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment25.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment1.png)
|
|
||||||
![](https://comments.iris-go.com/screens/comment2.png)
|
|
||||||
![](https://comments.iris-go.com/screens/comment3.png)
|
|
||||||
![](https://comments.iris-go.com/screens/comment4.png)
|
|
||||||
![](https://comments.iris-go.com/screens/comment5.png)
|
|
||||||
![](https://comments.iris-go.com/screens/comment6.png)
|
|
||||||
![](https://comments.iris-go.com/screens/comment7.png)
|
|
||||||
![](https://comments.iris-go.com/screens/comment8.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment10.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment12.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment13.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment14.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment17.png)
|
|
||||||
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment21.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment22.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment24.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment23.png)
|
|
||||||
|
|
||||||
![](https://comments.iris-go.com/screens/comment27.png)
|
|
19
_Footer.md
19
_Footer.md
|
@ -1,15 +1,4 @@
|
||||||
<div style="padding: 50px 0;color: #000;text-align: center;">
|
[[Home]] *|* [[About]] *|*
|
||||||
<a style="font-weight: 700;color: #000;margin: 4px;" href="mailto:kataras2006@hotmail.com?subject=Iris%20web%20framework">
|
[[Project|Project-and-community]] *|*
|
||||||
Mail
|
[[Getting Started]] *|*
|
||||||
</a>
|
[Technical Docs](https://godoc.org/github.com/kataras/iris) *|* Copyright © 2019 Gerasimos Maropoulos. [[Documentation terms of use|Documentation-terms-and-conditions]].
|
||||||
<a style="font-weight: 700;color: #000;margin: 4px;" target="_blank" href="https://www.facebook.com/iris.framework">
|
|
||||||
Facebook
|
|
||||||
</a>
|
|
||||||
<a style="font-weight: 700;color: #000;margin: 4px;" target="_blank" href="https://twitter.com/MakisMaropoulos">
|
|
||||||
Twitter
|
|
||||||
</a>
|
|
||||||
<br/>
|
|
||||||
<br/> Copyright © 2016 - 2017 Gerasimos Maropoulos
|
|
||||||
<br/>
|
|
||||||
<i style="font-size:13px">Iris is accelerated by <a style="font-weight: 700;color: #000;margin: 4px;" href="https://www.keycdn.com/">KeyCDN</a>, A Simple, Fast and Reliable CDN.</i>
|
|
||||||
</div>
|
|
||||||
|
|
129
_Sidebar.md
129
_Sidebar.md
|
@ -1,119 +1,10 @@
|
||||||
* [Why a new web framework](Why.md)
|
* [[About]]
|
||||||
* [Features](Features.md)
|
* [[Support]]
|
||||||
* [Versioning](Versioning.md)
|
* [[Installing Iris|Installation]]
|
||||||
* [Overview](https://github.com/kataras/iris/tree/master/_examples/#overview)
|
* [[Getting Started]]
|
||||||
* [Hello world!](https://github.com/kataras/iris/blob/master/_examples/hello-world/main.go)
|
* [[Routing]]
|
||||||
* [Glimpse](https://github.com/kataras/iris/blob/master/_examples/overview/main.go)
|
* [[Path Parameter Types|Routing-path-parameter-types]]
|
||||||
* [Tutorial: Online Visitors](https://github.com/kataras/iris/blob/master/_examples/tutorial/online-visitors)
|
* [[Reverse Lookups|Routing-reverse-lookups]]
|
||||||
* [Tutorial: URL Shortener using BoltDB](https://medium.com/@kataras/a-url-shortener-service-using-go-iris-and-bolt-4182f0b00ae7)
|
* [[Use and Write middleware|Routing-middleware]]
|
||||||
* [Tutorial: DropzoneJS + Go: How to build a file upload form](https://hackernoon.com/how-to-build-a-file-upload-form-using-dropzonejs-and-go-8fb9f258a991)
|
* [[Custom error handlers|Routing-error-handlers]]
|
||||||
* [Structuring](https://github.com/kataras/iris/tree/master/_examples/#structuring)
|
* [[Wrap the Router|Routing-wrap-the-router]]
|
||||||
* [Bootstrapper](https://github.com/kataras/iris/blob/master/_examples/structuring/bootstrap/bootstrap)
|
|
||||||
* [MVC with Repository and Service layer Overview](https://github.com/kataras/iris/tree/master/mvc/overview)
|
|
||||||
* [Login (MVC with Single Responsibility package)](https://github.com/kataras/iris/tree/master/structuring/login-mvc-single-responsible-package)
|
|
||||||
* [Login (MVC with Datamodels, Datasource, Repository and Service layer)](https://github.com/kataras/iris/tree/master/mvc/login)
|
|
||||||
* [HTTP Listening](https://github.com/kataras/iris/tree/master/_examples/#http-listening)
|
|
||||||
* [Common, with address](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-addr/main.go)
|
|
||||||
* [UNIX socket file](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-unix/main.go)
|
|
||||||
* [TLS](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-tls/main.go)
|
|
||||||
* [Letsencrypt (Automatic Certifications)](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-letsencrypt/main.go)
|
|
||||||
* [Custom net.Listener](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-listener/main.go)
|
|
||||||
* [SO_REUSEPORT for unix systems](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-listener/unix-reuseport/main.go)
|
|
||||||
* [Omit server errors](https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-addr/omit-server-errors/main.go)
|
|
||||||
* [Custom HTTP Server](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-httpserver/easy-way/main.go)
|
|
||||||
* [Custom HTTP Server (STD)](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-httpserver/std-way/main.go)
|
|
||||||
* [Multi HTTP Servers](https://github.com/kataras/iris/blob/master/_examples/http-listening/custom-httpserver/multi/main.go)
|
|
||||||
* [Graceful Shutdown](https://github.com/kataras/iris/blob/master/_examples/http-listening/graceful-shutdown/default-notifier/main.go)
|
|
||||||
* [Configuration](https://github.com/kataras/iris/tree/master/_examples/#configuration)
|
|
||||||
* [Functional](https://github.com/kataras/iris/blob/master/_examples/configuration/functional/main.go)
|
|
||||||
* [From Configuration Struct](https://github.com/kataras/iris/blob/master/_examples/configuration/from-configuration-structure/main.go)
|
|
||||||
* [Import from YAML file](https://github.com/kataras/iris/blob/master/_examples/configuration/from-yaml-file/main.go)
|
|
||||||
* [Import from TOML file](https://github.com/kataras/iris/blob/master/_examples/configuration/from-toml-file/main.go)
|
|
||||||
* [Routing](https://github.com/kataras/iris/tree/master/_examples/#routing-grouping-dynamic-path-parameters-macros-and-custom-context)
|
|
||||||
* [Overview](https://github.com/kataras/iris/blob/master/_examples/routing/overview/main.go)
|
|
||||||
* [Basic](https://github.com/kataras/iris/blob/master/_examples/routing/basic/main.go)
|
|
||||||
* [Custom HTTP Errors](https://github.com/kataras/iris/blob/master/_examples/routing/http-errors/main.go)
|
|
||||||
* [Dynamic Path](https://github.com/kataras/iris/blob/master/_examples/routing/dynamic-path/main.go)
|
|
||||||
* [Root level wildcard path](https://github.com/kataras/iris/blob/master/_examples/routing/dynamic-path/root-wildcard/main.go)
|
|
||||||
* [Reverse routing](https://github.com/kataras/iris/blob/master/_examples/routing/reverse/main.go)
|
|
||||||
* [Custom wrapper](https://github.com/kataras/iris/blob/master/_examples/routing/custom-wrapper/main.go)
|
|
||||||
* [Route State](https://github.com/kataras/iris/blob/master/_examples/routing/route-state/main.go)
|
|
||||||
* [MVC](https://github.com/kataras/iris/tree/master/_examples/#mvc)
|
|
||||||
* [Hello world](https://github.com/kataras/iris/tree/master/_examples/mvc/hello-world)
|
|
||||||
* [Session Controller](https://github.com/kataras/iris/tree/master/_examples/mvc/session-controller)
|
|
||||||
* [Overview - Plus Repository and Service layers](https://github.com/kataras/tree/tree/master/_examples/mvc/overview)
|
|
||||||
* [Login showcase - Plus Repository and Service layers](https://github.com/kataras/iris/tree/master/_examples/mvc/login)
|
|
||||||
* [Custom Context](https://github.com/kataras/iris/tree/master/_examples/routing/custom-context)
|
|
||||||
* [Method Overriding](https://github.com/kataras/iris/blob/master/_examples/routing/custom-context/method-overriding/main.go)
|
|
||||||
* [New Implementation](https://github.com/kataras/iris/blob/master/_examples/routing/custom-context/new-implementation/main.go)
|
|
||||||
* [Convert http.Handler](https://github.com/kataras/iris/tree/master/_examples/convert-handlers)
|
|
||||||
* [From func(http.ResponseWriter, *http.Request, http.HandlerFunc)](convert-handlers/negroni-like/main.go)
|
|
||||||
* [From http.Handler or http.HandlerFunc](convert-handlers/nethttp/main.go)
|
|
||||||
* [Subdomains](subdomains)
|
|
||||||
* [Single](https://github.com/kataras/iris/blob/master/_examples/subdomains/single/main.go)
|
|
||||||
* [Multi](https://github.com/kataras/iris/blob/master/_examples/subdomains/multi/main.go)
|
|
||||||
* [Wildcard](https://github.com/kataras/iris/blob/master/_examples/subdomains/wildcard/main.go)
|
|
||||||
* [WWW](https://github.com/kataras/iris/blob/master/_examples/subdomains/www/main.go)
|
|
||||||
* [View](https://github.com/kataras/iris/tree/master/_examples/#view)
|
|
||||||
* [Overview](https://github.com/kataras/iris/blob/master/_examples/view/overview/main.go)
|
|
||||||
* [Hi](https://github.com/kataras/iris/blob/master/_examples/view/template_html_0/main.go)
|
|
||||||
* [A simple Layout](https://github.com/kataras/iris/blob/master/_examples/view/template_html_1/main.go)
|
|
||||||
* [Layouts: `yield` and `render` tmpl funcs](https://github.com/kataras/iris/blob/master/_examples/view/template_html_2/main.go)
|
|
||||||
* [The `urlpath` tmpl func](https://github.com/kataras/iris/blob/master/_examples/view/template_html_3/main.go)
|
|
||||||
* [The `url` tmpl func](https://github.com/kataras/iris/blob/master/_examples/view/template_html_4/main.go)
|
|
||||||
* [Inject Data Between Handlers](https://github.com/kataras/iris/blob/master/_examples/view/context-view-data/main.go)
|
|
||||||
* [Embedding Templates Into App Executable File](https://github.com/kataras/iris/blob/master/_examples/view/embedding-templates-into-app/main.go)
|
|
||||||
* [Authentication](https://github.com/kataras/iris/tree/master/_examples/#authentication)
|
|
||||||
* [Basic Authentication](https://github.com/kataras/iris/blob/master/_examples/authentication/basicauth/main.go)
|
|
||||||
* [OAUth2](https://github.com/kataras/iris/blob/master/_examples/authentication/oauth2/main.go)
|
|
||||||
* [JWT](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/jwt/simple/main.go)
|
|
||||||
* [File Server](https://github.com/kataras/iris/tree/master/_examples/#file-server)
|
|
||||||
* [Favicon](https://github.com/kataras/iris/blob/master/_examples/file-server/favicon/main.go)
|
|
||||||
* [Basic](https://github.com/kataras/iris/blob/master/_examples/file-server/basic/main.go)
|
|
||||||
* [Embedding Files Into App Executable File](https://github.com/kataras/iris/blob/master/_examples/file-server/embedding-files-into-app/main.go)
|
|
||||||
* [Send/Force-Download Files](https://github.com/kataras/iris/blob/master/_examples/file-server/send-files/main.go)
|
|
||||||
* [Single Page Applications](https://github.com/kataras/iris/tree/master/_examples/file-server/single-page-application)
|
|
||||||
* [Single Page Application](https://github.com/kataras/iris/blob/master/_examples/file-server/single-page-application/basic/main.go)
|
|
||||||
* [Embedded Single Page Application](https://github.com/kataras/iris/blob/master/_examples/file-server/single-page-application/embedded-single-page-application/main.go)
|
|
||||||
* [Embedded Single Page Application with other routes](https://github.com/kataras/iris/blob/master/_examples/file-server/single-page-application/embedded-single-page-application-with-other-routes/main.go)
|
|
||||||
* [How to Read from *http.Request`](https://github.com/kataras/iris/tree/master/_examples/#how-to-read-from-contextrequest-httprequest)
|
|
||||||
* [Bind JSON](https://github.com/kataras/iris/blob/master/_examples/http_request/read-json/main.go)
|
|
||||||
* [Bind Form](https://github.com/kataras/iris/blob/master/_examples/http_request/read-form/main.go)
|
|
||||||
* [Upload/Read Files](https://github.com/kataras/iris/blob/master/_examples/http_request/upload-files/main.go)
|
|
||||||
* [How to Write to http.ResponseWriter](https://github.com/kataras/iris/tree/master/_examples/#how-to-write-to-contextresponsewriter-httpresponsewriter)
|
|
||||||
* [Write `valyala/quicktemplate` templates](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/quicktemplate/main.go)
|
|
||||||
* [Text, Markdown, HTML, JSON, JSONP, XML, Binary](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/write-rest/main.go)
|
|
||||||
* [Stream Writer](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/stream-writer/main.go)
|
|
||||||
* [Transactions](https://github.com/kataras/iris/blob/master/_examples/http_responsewriter/transactions/main.go)
|
|
||||||
* [Miscellaneous](https://github.com/kataras/iris/blob/master/_examples/#miscellaneous)
|
|
||||||
* [Request Logger](https://github.com/kataras/iris/blob/master/_examples/http_request/request-logger/main.go)
|
|
||||||
* [Log Requests to a file](https://github.com/kataras/iris/blob/master/_examples/http_request/request-logger/request-logger-file/main.go)
|
|
||||||
* [Localization and Internationalization](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/i18n/main.go)
|
|
||||||
* [Recovery](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/recover/main.go)
|
|
||||||
* [Profiling (pprof)](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/pprof/main.go)
|
|
||||||
* [Internal Application File Logger](https://github.com/kataras/iris/blob/master/_examples/miscellaneous/file-logger/main.go)
|
|
||||||
* [Testing](https://github.com/kataras/iris/blob/master/_examples/testing/httptest/main_test.go)
|
|
||||||
* [Caching](https://github.com/kataras/iris/blob/master/_examples/cache/simple/main.go)
|
|
||||||
* [Yaag - API Automated Docs](https://github.com/kataras/iris/blob/master/_examples/apidoc/yaag/main.go)
|
|
||||||
* [Sessions](https://github.com/kataras/iris/blob/master/_examples/#sessions)
|
|
||||||
* [Overview](https://github.com/kataras/iris/blob/master/_examples/sessions/overview/main.go)
|
|
||||||
* [Standalone](https://github.com/kataras/iris/blob/master/_examples/sessions/standalone/main.go)
|
|
||||||
* [Secure Cookie](https://github.com/kataras/iris/blob/master/_examples/sessions/securecookie/main.go)
|
|
||||||
* [Flash Messages](https://github.com/kataras/iris/blob/master/_examples/sessions/flash-messages/main.go)
|
|
||||||
* [Database](https://github.com/kataras/iris/blob/master/_examples/sessions/database/main.go)
|
|
||||||
* [Websockets](https://github.com/kataras/iris/tree/master/_examples/#websockets)
|
|
||||||
* [Chat](https://github.com/kataras/iris/blob/master/_examples/websocket/chat/main.go)
|
|
||||||
* [Native Messages](https://github.com/kataras/iris/blob/master/_examples/websocket/native-messages/main.go)
|
|
||||||
* [Connection List](https://github.com/kataras/iris/blob/master/_examples/websocket/connectionlist/main.go)
|
|
||||||
* [TLS Enabled](https://github.com/kataras/iris/blob/master/_examples/websocket/secure/main.go)
|
|
||||||
* [Custom Raw Go Client](https://github.com/kataras/iris/blob/master/_examples/websocket/custom-go-client/main.go)
|
|
||||||
* [Experimental Handlers](https://github.com/kataras/iris/tree/master/_examples/experimental-handlers)
|
|
||||||
* [Casbin wrapper](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/casbin/wrapper/main.go)
|
|
||||||
* [Casbin middleware](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/casbin/middleware/main.go)
|
|
||||||
* [Cloudwatch](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/cloudwatch/simple/main.go)
|
|
||||||
* [CORS](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/cors/simple/main.go)
|
|
||||||
* [JWT](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/jwt/main.go)
|
|
||||||
* [Newrelic](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/newrelic/simple/main.go)
|
|
||||||
* [Prometheus](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/prometheus/simple/main.go)
|
|
||||||
* [Secure](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/secure/simple/main.go)
|
|
||||||
* [Tollboothic](https://github.com/kataras/iris/blob/master/_examples/experimental-handlers/tollboothic/limit-handler/main.go)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user