Skip to content

Commit 7dab29c

Browse files
committed
update examples to latest Iris version
1 parent bb07696 commit 7dab29c

File tree

190 files changed

+5109
-7890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+5109
-7890
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.DS_STORE
12
.vscode
23
/issue-*/
34
/feature-*/

.travis.gofmt.sh

-7
This file was deleted.

.travis.gotest.sh

-11
This file was deleted.

.travis.yml

-17
This file was deleted.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016-2021 Gerasimos Maropoulos and contributors.
3+
Copyright (c) 2016-2022 Gerasimos Maropoulos and contributors.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+34-12
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
<a href="https://iris-go.com"> <img align="right" width="115px" src="https://iris-go.com/images/icon.svg?v=a" title="logo created by @merry.dii" /> </a>
44

5-
<a href="https://travis-ci.org/kataras/iris"><img src="https://img.shields.io/travis/kataras/iris.svg?style=flat-square" alt="Build Status"></a>
5+
<a href="https://github.com/kataras/iris/actions"><img src="https://img.shields.io/github/workflow/status/kataras/iris/CI/master?style=flat-square" alt="Build Status"></a>
66
<a href="https://github.com/iris-contrib/examples/blob/v12/LICENSE"><img src="https://img.shields.io/badge/%20license-MIT%20%20License%20-E91E63.svg?style=flat-square" alt="License"></a>
77
<a href="https://github.com/kataras/iris/blob/master/HISTORY.md"><img src="https://img.shields.io/badge/version-v12.2.x%20-blue.svg?style=flat-square" alt="CHANGELOG/HISTORY"></a>
88

99
This repository provides easy to understand code snippets on how to get started with web development with the Go programming language using the [Iris](https://github.com/kataras/iris) web framework. This branch contains the latest [iris master examples](github.com/kataras/iris/tree/master). For the stable's version examples navigate through the [v12 branch](https://github.com/iris-contrib/examples/tree/v12).
1010

1111
To read the Iris documentation please navigate to [the wiki pages](https://github.com/kataras/iris/wiki) instead.
1212

13-
> Examples are tested using Windows 10, Ubuntu 20.04 with [Microsoft's Visual Studio Code](https://code.visualstudio.com/) and built using the [Go 1.15.0](https://golang.org/dl).
13+
> Examples are tested using Windows 11, Ubuntu 22.04 LTS, macOS 12 Monterey with [Microsoft's Visual Studio Code](https://code.visualstudio.com/) and built using the [Go 1.19.rc2](https://go.dev/dl/).
1414
1515
# Table of Contents
1616

@@ -19,13 +19,18 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
1919
* [URL Shortener](url-shortener)
2020
* [Dropzone.js](dropzonejs)
2121
* [Caddy](caddy)
22+
* [Bootstrapper](bootstrapper)
23+
* [Project Structure](project) :fire:
24+
* Monitor
25+
* [Simple Process Monitor (includes UI)](monitor/monitor-middleware/main.go) **NEW**
26+
* [Heap, MSpan/MCache, Size Classes, Objects, Goroutines, GC/CPU fraction (includes UI)](monitor/statsviz/main.go) **NEW**
2227
* Database
2328
* [MySQL, Groupcache & Docker](database/mysql)
2429
* [MongoDB](database/mongodb)
2530
* [Sqlx](database/orm/sqlx/main.go)
26-
* [Xorm](database/orm/xorm/main.go)
2731
* [Gorm](database/orm/gorm/main.go)
2832
* [Reform](database/orm/reform/main.go)
33+
* [x/sqlx](database/sqlx/main.go) **NEW**
2934
* HTTP Server
3035
* [HOST:PORT](http-server/listen-addr/main.go)
3136
* [Public Test Domain](http-server/listen-addr-public/main.go)
@@ -42,17 +47,25 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
4247
* [Use Iris as a single http.Handler](http-server/custom-httpserver/std-way/main.go)
4348
* [Multi Instances](http-server/custom-httpserver/multi/main.go)
4449
* [HTTP/3 Quic](http-server/http3-quic)
50+
* [H2C](http-server/h2c/main.go) **NEW**
51+
* [Timeout](http-server/timeout/main.go)
52+
* HTTP Client
53+
* [Weather Client](http-client/weatherapi)
4554
* Configuration
4655
* [Functional](configuration/functional/main.go)
4756
* [Configuration Struct](configuration/from-configuration-structure/main.go)
4857
* [Using Viper](configuration/viper)
4958
* [Import from YAML](configuration/from-yaml-file/main.go)
5059
* [Share Configuration across instances](configuration/from-yaml-file/shared-configuration/main.go)
5160
* [Import from TOML](configuration/from-toml-file/main.go)
61+
* [Multi Environment Configuration](configuration/multi-environments) **NEW**
5262
* Routing
63+
* [Party Controller](routing/party-controller) **NEW**
5364
* [Overview](routing/overview/main.go)
5465
* [Basic](routing/basic/main.go)
5566
* [Custom HTTP Errors](routing/http-errors/main.go)
67+
* [HTTP Wire Errors](routing/http-wire-errors/main.go) **NEW**
68+
* [Custom Validation Errors](routing/http-wire-errors/custom-validation-errors/main.go)
5669
* [Not Found - Intelligence](routing/intelligence/main.go)
5770
* [Not Found - Suggest Closest Paths](routing/intelligence/manual/main.go)
5871
* [Dynamic Path](routing/dynamic-path/main.go)
@@ -62,6 +75,7 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
6275
* Middleware
6376
* [Per Route](routing/writing-a-middleware/per-route/main.go)
6477
* [Globally](routing/writing-a-middleware/globally/main.go)
78+
* [Remove a Handler](routing/remove-handler/main.go)
6579
* Share Values
6680
* [Share Services](routing/writing-a-middleware/share-services/main.go)
6781
* [Share Functions](routing/writing-a-middleware/share-funcs/main.go)
@@ -70,9 +84,11 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
7084
* Convert net/http Handlers
7185
* [From func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)](convert-handlers/negroni-like/main.go)
7286
* [From http.Handler or http.HandlerFunc](convert-handlers/nethttp/main.go)
73-
* [From func(http.HandlerFunc) http.HandlerFunc](convert-handlers/real-usecase-raven/writing-middleware/main.go)
87+
* [From func(http.Handler) http.Handler](convert-handlers/wrapper/main.go)
88+
* [Convert by your own: sentry/raven middleware](convert-handlers/real-usecase-raven/writing-middleware/main.go)
7489
* [Rewrite Middleware](routing/rewrite/main.go)
7590
* [Route State](routing/route-state/main.go)
91+
* [Remove Route](routing/remove-route/main.go)
7692
* [Reverse Routing](routing/reverse/main.go)
7793
* [Router Wrapper](routing/custom-wrapper/main.go)
7894
* [Custom Router](routing/custom-router/main.go)
@@ -100,11 +116,13 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
100116
* [The CSV Formatter](logging/request-logger/accesslog-csv/main.go)
101117
* [Create your own Formatter](logging/request-logger/accesslog-formatter/main.go)
102118
* [Root and Proxy AccessLog instances](logging/request-logger/accesslog-proxy/main.go)
119+
* [Slack integration example](logging/request-logger/accesslog-slack/main.go)
103120
* API Documentation
104121
* [Yaag](apidoc/yaag/main.go)
105-
* [Swagger](https://github.com/iris-contrib/swagger/tree/master/example)
122+
* [Swagger](https://github.com/iris-contrib/swagger/tree/master/_examples/basic)
106123
* [Testing](testing/httptest/main_test.go)
107124
* [Recovery](recover/main.go)
125+
* [Panic and custom Error Handler with Compression](recover/panic-and-custom-error-handler-with-compression/main.go)
108126
* [Profiling](pprof/main.go)
109127
* File Server
110128
* [File Server](file-server/file-server/main.go)
@@ -123,6 +141,7 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
123141
* [Embedded Single Page Application with other routes](file-server/single-page-application/embedded-single-page-application-with-other-routes/main.go)
124142
* [Upload File](file-server/upload-file/main.go)
125143
* [Upload Multiple Files](file-server/upload-files/main.go)
144+
* [WebDAV](file-server/webdav/main.go)
126145
* View
127146
* [Overview](view/overview/main.go)
128147
* [Layout](view/layout)
@@ -174,6 +193,7 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
174193
* [Webassembly](webassembly/main.go)
175194
* Request Body
176195
* [Bind JSON](request-body/read-json/main.go)
196+
* * [JSON Stream and disable unknown fields](request-body/read-json-stream/main.go)
177197
* * [Struct Validation](request-body/read-json-struct-validation/main.go)
178198
* [Bind XML](request-body/read-xml/main.go)
179199
* [Bind MsgPack](request-body/read-msgpack/main.go)
@@ -195,9 +215,9 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
195215
* [Protocol Buffers](response-writer/protobuf/main.go)
196216
* [HTTP/2 Server Push](response-writer/http2push/main.go)
197217
* [Stream Writer](response-writer/stream-writer/main.go)
198-
* [Transactions](response-writer/transactions/main.go)
199-
* [SSE](response-writer/sse/main.go)
200-
* [SSE (third-party package usage for server sent events)](response-writer/sse-third-party/main.go)
218+
* [Server-Sent Events](response-writer/sse/main.go)
219+
* [SSE 3rd-party (r3labs/sse)](response-writer/sse-third-party/main.go)
220+
* [SSE 3rd-party (alexandrevicenzi/go-sse)](response-writer/sse-third-party-2/main.go)
201221
* Cache
202222
* [Simple](response-writer/cache/simple/main.go)
203223
* [Client-Side (304)](response-writer/cache/client-side/main.go)
@@ -209,7 +229,8 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
209229
* [Basic](i18n/basic)
210230
* [Ttemplates and Functions](i18n/template)
211231
* [Pluralization and Variables](i18n/plurals)
212-
* Authentication, Authorization & Bot Detection
232+
* Authentication, Authorization & Bot Detection
233+
* [Recommended: Auth package and Single-Sign-On](auth/auth) **NEW (GO 1.18 Generics required)**
213234
* Basic Authentication
214235
* [Basic](auth/basicauth/basic)
215236
* [Load from a slice of Users](auth/basicauth/users_list)
@@ -267,12 +288,14 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
267288
* [Hello world](mvc/hello-world/main.go)
268289
* [Basic](mvc/basic/main.go)
269290
* [Wildcard](mvc/basic/wildcard/main.go)
291+
* [Default request values](mvc/request-default-values/main.go)
270292
* [Singleton](mvc/singleton)
271293
* [Regexp](mvc/regexp/main.go)
272294
* [Session Controller](mvc/session-controller/main.go)
273295
* [Authenticated Controller](mvc/authenticated-controller/main.go)
274296
* [Versioned Controller](mvc/versioned-controller/main.go)
275297
* [Websocket Controller](mvc/websocket)
298+
* [Websocket + Authentication (Single-Sign-On)](mvc/websocket-auth) **NEW (GO 1.18 Generics required)**
276299
* [Register Middleware](mvc/middleware)
277300
* [gRPC](mvc/grpc-compatible)
278301
* [gRPC Bidirectional Stream](mvc/grpc-compatible-bidirectional-stream)
@@ -284,7 +307,6 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
284307
* [Handle errors using mvc.Result](mvc/error-handler-custom-result)
285308
* [Handle errors using PreflightResult](mvc/error-handler-preflight)
286309
* [Handle errors by hijacking the result](mvc/error-handler-hijack)
287-
* [Bootstrapper](bootstrapper)
288310
* Desktop Applications
289311
* [The blink package](desktop/blink)
290312
* [The lorca package](desktop/lorca)
@@ -293,9 +315,9 @@ To read the Iris documentation please navigate to [the wiki pages](https://githu
293315

294316
## Run
295317

296-
1. Install the Go Programming Language, version 1.15+ from [here](https://golang.org/dl).
318+
1. Install the Go Programming Language, version 1.18+ from [here](https://go.dev/dl/).
297319
2. [Download the examples](https://github.com/iris-contrib/examples/archive/master.zip) and copy-paste them to your `$GOPATH/src/github.com/iris-contrib/examples`
298-
3. Install Iris with `go get -u github.com/kataras/iris/[email protected]alpha2`
320+
3. Install Iris with `go get -u github.com/kataras/iris/[email protected]beta3`
299321

300322
To run an example, open a terminal session and execute:
301323

apidoc/yaag/go.mod

+50-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,56 @@
11
module github.com/iris-contrib/examples/apidoc/yaag
22

3-
go 1.15
3+
go 1.18
44

55
require (
66
github.com/betacraft/yaag v1.0.1-0.20200719063524-47d781406108
7-
github.com/kataras/iris/v12 master
7+
github.com/kataras/iris/v12 v12.2.0-beta3
8+
)
9+
10+
require (
11+
github.com/BurntSushi/toml v1.1.0 // indirect
12+
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
13+
github.com/CloudyKit/jet/v6 v6.1.0 // indirect
14+
github.com/Shopify/goreferrer v0.0.0-20210630161223-536fa16abd6f // indirect
15+
github.com/andybalholm/brotli v1.0.4 // indirect
16+
github.com/aymerick/douceur v0.2.0 // indirect
17+
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 // indirect
18+
github.com/fatih/structs v1.1.0 // indirect
19+
github.com/flosch/pongo2/v4 v4.0.2 // indirect
20+
github.com/goccy/go-json v0.9.8-0.20220506185958-23bd66f4c0d5 // indirect
21+
github.com/golang/snappy v0.0.4 // indirect
22+
github.com/google/uuid v1.3.0 // indirect
23+
github.com/gorilla/css v1.0.0 // indirect
24+
github.com/iris-contrib/jade v1.1.4 // indirect
25+
github.com/iris-contrib/schema v0.0.6 // indirect
26+
github.com/josharian/intern v1.0.0 // indirect
27+
github.com/json-iterator/go v1.1.12 // indirect
28+
github.com/kataras/blocks v0.0.5 // indirect
29+
github.com/kataras/golog v0.1.7 // indirect
30+
github.com/kataras/pio v0.0.10 // indirect
31+
github.com/kataras/sitemap v0.0.5 // indirect
32+
github.com/kataras/tunnel v0.0.4 // indirect
33+
github.com/klauspost/compress v1.15.5 // indirect
34+
github.com/mailgun/raymond/v2 v2.0.46 // indirect
35+
github.com/mailru/easyjson v0.7.7 // indirect
36+
github.com/microcosm-cc/bluemonday v1.0.18 // indirect
37+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
38+
github.com/modern-go/reflect2 v1.0.2 // indirect
39+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
40+
github.com/schollz/closestmatch v2.1.0+incompatible // indirect
41+
github.com/sirupsen/logrus v1.8.1 // indirect
42+
github.com/tdewolff/minify/v2 v2.11.7 // indirect
43+
github.com/tdewolff/parse/v2 v2.5.32 // indirect
44+
github.com/valyala/bytebufferpool v1.0.0 // indirect
45+
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
46+
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
47+
github.com/yosssi/ace v0.0.5 // indirect
48+
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 // indirect
49+
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
50+
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 // indirect
51+
golang.org/x/text v0.3.7 // indirect
52+
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
53+
google.golang.org/protobuf v1.28.0 // indirect
54+
gopkg.in/ini.v1 v1.66.6 // indirect
55+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
856
)

auth/auth/README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Auth Package (+ Single Sign On)
2+
3+
```sh
4+
$ go run .
5+
```
6+
7+
1. GET/POST: http://localhost:8080/signin
8+
2. GET: http://localhost:8080/member
9+
3. GET: http://localhost:8080/owner
10+
4. POST: http://localhost:8080/refresh
11+
5. GET: http://localhost:8080/signout
12+
6. GET: http://localhost:8080/signout-all

auth/auth/auth.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Headers: # required.
2+
- "Authorization"
3+
- "X-Authorization"
4+
Cookie: # optional.
5+
Name: "iris_auth_cookie"
6+
Secure: false
7+
Hash: "D*G-KaPdSgUkXp2s5v8y/B?E(H+MbQeThWmYq3t6w9z$C&F)J@NcRfUjXn2r4u7x" # length of 64 characters (512-bit).
8+
Block: "VkYp3s6v9y$B&E)H@McQfTjWmZq4t7w!" # length of 32 characters (256-bit).
9+
Keys:
10+
- ID: IRIS_AUTH_ACCESS # required.
11+
Alg: EdDSA
12+
MaxAge: 2h # 2 hours lifetime for access tokens.
13+
Private: |+
14+
-----BEGIN PRIVATE KEY-----
15+
MC4CAQAwBQYDK2VwBCIEIFdZWoDdFny5SMnP9Fyfr8bafi/B527EVZh8JJjDTIFO
16+
-----END PRIVATE KEY-----
17+
Public: |+
18+
-----BEGIN PUBLIC KEY-----
19+
MCowBQYDK2VwAyEAzpgjKSr9E032DX+foiOxq1QDsbzjLxagTN+yVpGWZB4=
20+
-----END PUBLIC KEY-----
21+
- ID: IRIS_AUTH_REFRESH # optional. Good practise to have it though.
22+
Alg: EdDSA
23+
# 1 month lifetime for refresh tokens,
24+
# after that period the user has to signin again.
25+
MaxAge: 720h
26+
Private: |+
27+
-----BEGIN PRIVATE KEY-----
28+
MC4CAQAwBQYDK2VwBCIEIHJ1aoIjA2sRp5eqGjGR3/UMucrHbBdBv9p8uwfzZ1KZ
29+
-----END PRIVATE KEY-----
30+
Public: |+
31+
-----BEGIN PUBLIC KEY-----
32+
MCowBQYDK2VwAyEAsKKAr+kDtfAqwG7cZdoEAfh9jHt9W8qi9ur5AA1KQAQ=
33+
-----END PUBLIC KEY-----
34+
# Example of setting a binary form of the encryption key for refresh tokens,
35+
# it could be a "string" as well.
36+
EncryptionKey: !!binary stSNLTu91YyihPxzeEOXKwGVMG00CjcC/68G8nMgmqA=

0 commit comments

Comments
 (0)