Align doc.go

Former-commit-id: 6d78bc5aec83ddeb15e068679ec1da33fd16e32e
This commit is contained in:
Gerasimos (Makis) Maropoulos 2017-02-16 18:27:34 +02:00
parent 1851d49b58
commit 5a1e9cd13f

26
doc.go
View File

@ -67,7 +67,6 @@ Example code:
// Handler(s): index
app.Get("/", index)
app.Listen(":80")
}
@ -76,6 +75,7 @@ Example code:
}
All HTTP methods are supported, users can register handlers for same paths on different methods.
The first parameter is the HTTP Method,
second parameter is the request path of the route,
@ -379,27 +379,31 @@ Example code:
package main
import (
"gopkg.in/kataras/iris.v6"
"github.com/kataras/adaptors/gorillamux"
"github.com/rs/cors"
"gopkg.in/kataras/iris.v6"
"gopkg.in/kataras/iris.v6/adaptors/gorillamux"
)
// myCors returns a new cors middleware
// newCorsMiddleware returns a new cors middleware
// with the provided options.
myCors := func(opts cors.Options) iris.HandlerFunc {
handlerWithNext := cors.New(opts).ServeHTTP
func newCorsMiddleware() iris.HandlerFunc {
options := cors.Options{
AllowedOrigins: []string{"*"},
}
handlerWithNext := cors.New(options).ServeHTTP
// this is the only func you will have to use if you're going to make use of any external net/http middleware.
// this is the only func you will have to use if you're going
// to make use of any external net/http middleware.
// iris.ToHandler converts the net/http middleware to an iris-compatible.
return iris.ToHandler(handlerWithNext)
}
func main() {
app := iris.New()
app.Adapt(httprouter.New())
app.Adapt(gorillamux.New())
// Any registers a route to all http methods.
app.Any("/user", myCors(cors.Options{AllowOrigins: "*"}), func(ctx *iris.Context){
app.Any("/user", newCorsMiddleware(), func(ctx *iris.Context) {
// ....
})
@ -432,7 +436,7 @@ like Layout, Template Funcs, Party-specific layout, partial rendering and more.
its template parser is the https://github.com/eknkc/amber
Each one of these template engines has different options,
view adaptors are located here: https://github.com/kataras/iris/tree/master/adaptors/view .
view adaptors are located here: https://github.com/kataras/iris/tree/v6/adaptors/view .
Example code:
@ -487,6 +491,7 @@ Example code:
app.Listen(":8080")
}
View engine supports bundled(https://github.com/jteeuwen/go-bindata) template files too.
go-bindata gives you two functions, asset and assetNames,
these can be setted to each of the template engines using the `.Binary` func.
@ -514,7 +519,6 @@ You should have a basic idea of the framework by now, we just scratched the surf
If you enjoy what you just saw and want to learn more, please follow the below links:
- examples: https://github.com/iris-contrib/examples
- book: https://docs.iris-go.com
- adaptors: https://github.com/kataras/iris/tree/v6/adaptors
- middleware: https://github.com/kataras/iris/tree/v6/middleware & https://github.com/iris-contrib/middleware
- godocs: https://godoc.org/github.com/kataras/iris