From f747c682b9017508582fb664c4e468173db2a61b Mon Sep 17 00:00:00 2001 From: kataras Date: Thu, 8 Jun 2017 19:10:03 +0300 Subject: [PATCH] Add links for JWT & Cors examples Former-commit-id: e33281d352841749638d68faa5fcb42d7473860b --- _examples/README.md | 4 +- _examples/intermediate/cors/main.go | 57 ----------------------------- 2 files changed, 3 insertions(+), 58 deletions(-) delete mode 100644 _examples/intermediate/cors/main.go diff --git a/_examples/README.md b/_examples/README.md index a0982ee4..23668ffb 100644 --- a/_examples/README.md +++ b/_examples/README.md @@ -44,7 +44,9 @@ It doesn't contains "best ways" neither explains all its features. It's just a s * [Request Logger](beginner/request-logger/main.go) * [Basic Authentication](beginner/basicauth/main.go) * [Level: Intermediate](intermediate) + * [JWT](https://github.com/iris-contrib/middleware/blob/master/jwt/_example/main.go) * [OAUth2](intermediate/oauth2/main.go) + * [CORS](https://github.com/iris-contrib/middleware/blob/master/cors/_example/main.go) * [Transactions](intermediate/transactions/main.go) * [HTTP Testing](intermediate/httptest/main_test.go) * [Watch & Compile Typescript source files](intermediate/typescript/main.go) @@ -89,7 +91,7 @@ It doesn't contains "best ways" neither explains all its features. It's just a s * [Subdomains](intermediate/subdomains) * [Single](intermediate/subdomains/single/main.go) * [Multi](intermediate/subdomains/multi/main.go) - * [Wildcard](intermediate/subdomains/wildcard/main.go) + * [Wildcard](intermediate/subdomains/wildcard/main.go) * [Level: Advanced](advanced) * [Online Visitors](advanced/online-visitors/main.go) * [URL Shortener using BoltDB](advanced/url-shortener/main.go) diff --git a/_examples/intermediate/cors/main.go b/_examples/intermediate/cors/main.go deleted file mode 100644 index 0ecc659d..00000000 --- a/_examples/intermediate/cors/main.go +++ /dev/null @@ -1,57 +0,0 @@ -package main - -// We don't have to reinvert the wheel, so we will use a good cors middleware -// as a router wrapper for our entire app. -// Follow the steps below: -// +------------------------------------------------------------+ -// | Cors installation | -// +------------------------------------------------------------+ -// go get -u github.com/rs/cors -// -// +------------------------------------------------------------+ -// | Cors wrapper usage | -// +------------------------------------------------------------+ -// import "github.com/rs/cors" -// -// app := iris.New() -// corsOptions := cors.Options{/* your options here */} -// corsWrapper := cors.New(corsOptions).ServeHTTP -// app.Wrap(corsWrapper) -// -// [your code goes here...] -// -// app.Run(iris.Addr(":8080")) - -import ( - "github.com/rs/cors" - - "github.com/kataras/iris" - "github.com/kataras/iris/context" -) - -func main() { - - app := iris.New() - corsOptions := cors.Options{ - AllowedOrigins: []string{"*"}, - AllowCredentials: true, - } - - corsWrapper := cors.New(corsOptions).ServeHTTP - - app.WrapRouter(corsWrapper) - - v1 := app.Party("/api/v1") - { - v1.Get("/", h) - v1.Put("/put", h) - v1.Post("/post", h) - } - - app.Run(iris.Addr(":8080")) -} - -func h(ctx context.Context) { - ctx.Application().Log(ctx.Path()) - ctx.Writef("Hello from %s", ctx.Path()) -}