Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade: v11.2.0 #1175

Merged
merged 91 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
dee3e6b
init of v11.2.0: add context#FullRequestURI and NewConditionalHandler
kataras Jan 19, 2019
bd1ada4
minor misspell fix
kataras Jan 19, 2019
48cfac9
gofmt
kataras Jan 19, 2019
32d735f
add a warning on mvc if someone didn't read the examples or the godoc…
kataras Jan 20, 2019
9a777f7
websocket: replace sync.Map with custom map[string]*connection. Add t…
kataras Jan 25, 2019
4cfdc64
add tutorial for the official mongodb go driver
kataras Jan 28, 2019
0b860fa
minor fmt
kataras Feb 2, 2019
07e9179
add Context#ResetRequest and core/handlerconv.FromStdWithNext updates…
kataras Feb 2, 2019
1a8d162
minor
kataras Feb 2, 2019
90784f3
add iris websocket client side for Go and a simple chat example
kataras Feb 9, 2019
edaf461
use the same connection structure for both client and server-side con…
kataras Feb 10, 2019
71ad442
add websocket client stress test, passed and update the vendors (this…
kataras Feb 14, 2019
cea2375
add support for mvc and hero dynamic dependencies to understand the e…
kataras Feb 15, 2019
1fef41a
sessions: give ability to the end-user to modify the cookie via conte…
kataras Feb 16, 2019
63c6ae7
add a new websocket2 package without breaking changes to the iris API…
kataras Feb 17, 2019
f39dffc
fix issue on binding sessions caused by variadic cookie options, as r…
kataras Feb 17, 2019
e5d0702
websocket: from 1k to 100k on a simple raspeberry pi 3 model b by usi…
kataras Feb 18, 2019
7ed238a
improve client test, I think we are OK, both gorilla(websocket) and w…
kataras Feb 19, 2019
1cf47da
some cleanup, and remove the test 'testwebocket2' package at all; A l…
kataras Feb 22, 2019
decd933
add `Context.ResponseWriter.IsHijacked` to report whether the underli…
kataras Feb 23, 2019
328b5c6
remove websocket's connection's temp storage, as it was deprecated fo…
kataras Feb 23, 2019
ffcb1b8
fix https://github.com/kataras/iris/issues/1205
kataras Mar 1, 2019
86e06cb
implement mvc HandleError as requested at #1244
kataras Apr 16, 2019
5a543d8
clean up the mvc error handler example
kataras Apr 16, 2019
18004a4
extract the `Delim` for redis sessiondb as requested at https://githu…
kataras May 30, 2019
1e95695
fix go.mod caused by prev commit
kataras May 30, 2019
d1fd8b2
Add the new websocket package (which is just a helper for kataras/nef…
kataras Jun 2, 2019
fa87c95
add example line on how to get the upgraded conn's `iris.Context` wit…
kataras Jun 2, 2019
e00ec93
add go1.12 to the travis builds (there are 4 tested versions, and thi…
kataras Jun 2, 2019
02ca842
add `neffos.Object` based on the latest neffos API and update the go.…
kataras Jun 3, 2019
a4fbbd3
updates for neffos and re-push the fix of the request path with uri u…
kataras Jun 6, 2019
ce975f3
sync master README.md: video courses, articles and starter kits
kataras Jun 12, 2019
c7d5c83
_examples/websocket/basic: add a nodejs client and provide a README.m…
kataras Jun 13, 2019
56754d7
fix https://github.com/kataras/iris/issues/1273
kataras Jun 14, 2019
6c50e6a
hero/mvc: func result -> struct, map, slices check if content type is…
kataras Jun 14, 2019
9fef498
hero/mvc: func result -> struct, map, slices check if content type is…
kataras Jun 14, 2019
3145586
add more websocket helpers from neffos project
kataras Jun 15, 2019
7974f80
add a `Route#StaticTarget string` to determinate if a specific route …
kataras Jun 15, 2019
7c78079
create the new FileServer and HandleDir, deprecate the rest APIBuilde…
kataras Jun 21, 2019
fb6d94e
fix travis fail on deprecation example test
kataras Jun 21, 2019
af54418
replace the redis library we used with another one, no performance di…
kataras Jun 22, 2019
82aa362
Implement a new View Engine for the Jet template parser as requested …
kataras Jun 22, 2019
5093cc8
a good start of making the ./_benchmarks benchmarker works autonomous…
kataras Jun 23, 2019
ba2f030
finally make the silent and local installation for nodejs get working…
kataras Jun 23, 2019
d225104
fix https://github.com/kataras/iris/issues/1286
kataras Jun 23, 2019
7cee1b4
nothing serious here yet, just having fun with powershell and my nerv…
kataras Jun 24, 2019
b84447e
remove the json-iterator from vendor, keep its most stable version on…
kataras Jun 24, 2019
0434bde
update the nantive-messages(only) example to the latest websocket (mi…
kataras Jun 25, 2019
58731c1
nothing tremendous here
kataras Jun 27, 2019
2e839c1
add the DefaultIDGenerator as variable to the iris neffos helpers
kataras Jul 1, 2019
f806e99
update websocket examples - keep neffos and use the iris/websocket as…
kataras Jul 1, 2019
660849d
implement the Iris Crypto Library for Request Authentication and Veri…
kataras Jul 2, 2019
a95c7a6
add support for iris-specific form of generating connection IDs as re…
kataras Jul 5, 2019
e2a06eb
improve the example and add jwt authentication on handshake or server…
kataras Jul 6, 2019
ab321a6
MVC improvements: add HandleWebsocket that now registers events autom…
kataras Jul 9, 2019
df66284
minor example fixes
kataras Jul 9, 2019
2fe5597
Remove the two day old crypto package, let's not confuse users betwee…
kataras Jul 9, 2019
f0ab69d
add running with http/3 quic protocol as server listener to examples,…
kataras Jul 9, 2019
eafbce2
add the new neffos StackExchange feature to the type aliases and shor…
kataras Jul 11, 2019
a71ad42
add HandleMany to controller's Before/AfterActivation feature as requ…
kataras Jul 11, 2019
0d4f247
add support for b.HandleMany(GET, /custom3/{ps:string}/{pssecond:stri…
kataras Jul 11, 2019
bf3f306
respect the WithoutBodyConsumptionOnUnmarshal on 'ctx.ReadForm' and '…
kataras Jul 12, 2019
f5b810d
sync kataras/iris/websocket with kataras/neffos - added support for n…
kataras Jul 14, 2019
242cc32
Updated all dependencies one by one to go.mod - Backup and remove the…
kataras Jul 15, 2019
19da9e8
update mongodb official driver tutorial to its latest API (requires a…
kataras Jul 15, 2019
4dcf6b9
nothing important here
kataras Jul 15, 2019
0558230
hmm
kataras Jul 15, 2019
efaf87c
remove experimental-handlers examples, users should visit github.com/…
kataras Jul 15, 2019
099cdaa
update the online visitors and vuejs +iris mvc todo app (this gave me…
kataras Jul 15, 2019
55350ba
start of the server tunneling feature - probably will help new users …
kataras Jul 16, 2019
5045552
all examples and tests ran successfully based on iris v11.2.0 and go+…
kataras Jul 16, 2019
3cd0837
New feature: automatic public domain using tunneling: https://github.…
kataras Jul 17, 2019
12dd190
minor
kataras Jul 19, 2019
0854c15
able to fetch the ngrok executable path through a 'NGROK' env variabl…
kataras Jul 19, 2019
f6e78f0
touches before release
kataras Jul 22, 2019
1ca7a36
align image (try 1)
kataras Jul 22, 2019
9c4105e
align image (try 2)
kataras Jul 22, 2019
76248e8
align image (try 2)
kataras Jul 22, 2019
81e6a1a
minify README.md
kataras Jul 22, 2019
607b5b7
https://github.com/kataras/iris/issues/1217
kataras Jul 22, 2019
4469d50
fossa
kataras Jul 22, 2019
3fb52c0
readme needs new translations as it's minified and dramatically changed
kataras Jul 22, 2019
d1c90f3
minor
kataras Jul 22, 2019
29425b5
minor
kataras Jul 22, 2019
15fab43
remove some examples learning content as they are exist on the wiki i…
kataras Jul 23, 2019
46a917b
add the gorm example from: https://github.com/kataras/iris/pull/1275
kataras Jul 23, 2019
7db4c62
resolve conflicts with current master v11.1.1
kataras Jul 23, 2019
b089061
remove the old redis (result of prev commit sync with master)
kataras Jul 23, 2019
a12e467
release 11.2.0
kataras Jul 23, 2019
31c9880
from master
kataras Jul 23, 2019
b79cd8f
Merge branch 'master' into v11.2.0
kataras Jul 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Developers are not forced to upgrade if they don't really need it. Upgrade whene

**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris` or let the automatic updater do that for you.

# Soon

Coming soon, stay tuned by reading the [PR](https://github.com/kataras/iris/pull/1175) progress.

# Fr, 11 January 2019 | v11.1.1

Happy new year! This is a minor release, contains mostly bug fixes.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ Iris, unlike others, is 100% compatible with the standards and that's why the ma

## Support

- [HISTORY](HISTORY.md#fr-11-january-2019--v1111) file is your best friend, it contains information about the latest features and changes
- [HISTORY](HISTORY.md#soon) file is your best friend, it contains information about the latest features and changes
- Did you happen to find a bug? Post it at [github issues](https://github.com/kataras/iris/issues)
- Do you have any questions or need to speak with someone experienced to solve a problem at real-time? Join us to the [community chat](https://chat.iris-go.com)
- Complete our form-based user experience report by clicking [here](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.1.1:https://github.com/kataras/iris/blob/master/HISTORY.md#fr-11-january-2019--v1111
11.2.0:https://github.com/kataras/iris/blob/master/HISTORY.md#soon
7,118 changes: 3,556 additions & 3,562 deletions _examples/file-server/embedding-gziped-files-into-app/bindata_gzip.go

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions _examples/miscellaneous/i18n/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ func newApp() *iris.Application {
"key2", fromSecondFileValue)
})

// using in inside your templates:
view := iris.HTML("./templates", ".html")
app.RegisterView(view)

app.Get("/templates", func(ctx iris.Context) {
ctx.View("index.html", iris.Map{
"tr": ctx.Translate,
})
// it will return "hello, iris"
// when {{call .tr "hi" "iris"}}
})
//

return app
}

Expand Down
1 change: 1 addition & 0 deletions _examples/miscellaneous/i18n/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{call .tr "hi" "iris"}}
2 changes: 2 additions & 0 deletions _examples/mvc/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"fmt"

"github.com/kataras/iris"
"github.com/kataras/iris/middleware/recover"
"github.com/kataras/iris/sessions"

"github.com/kataras/iris/mvc"
)

func main() {
app := iris.New()
app.Use(recover.New())
app.Logger().SetLevel("debug")
mvc.Configure(app.Party("/basic"), basicMVC)

Expand Down
49 changes: 49 additions & 0 deletions _examples/routing/conditional-chain/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package main

import (
"github.com/kataras/iris"
)

func main() {
app := iris.New()
v1 := app.Party("/api/v1")

myFilter := func(ctx iris.Context) bool {
// don't do that on production, use session or/and database calls and etc.
ok, _ := ctx.URLParamBool("admin")
return ok
}

onlyWhenFilter1 := func(ctx iris.Context) {
ctx.Application().Logger().Infof("admin: %s", ctx.Params())
ctx.Next()
}

onlyWhenFilter2 := func(ctx iris.Context) {
// You can always use the per-request storage
// to perform actions like this ofc.
//
// this handler: ctx.Values().Set("is_admin", true)
// next handler: isAdmin := ctx.Values().GetBoolDefault("is_admin", false)
//
// but, let's simplify it:
ctx.HTML("<h1>Hello Admin</h1><br>")
ctx.Next()
}

// HERE:
// It can be registered anywhere, as a middleware.
// It will fire the `onlyWhenFilter1` and `onlyWhenFilter2` as middlewares (with ctx.Next())
// if myFilter pass otherwise it will just continue the handler chain with ctx.Next() by ignoring
// the `onlyWhenFilter1` and `onlyWhenFilter2`.
myMiddleware := iris.NewConditionalHandler(myFilter, onlyWhenFilter1, onlyWhenFilter2)

v1UsersRouter := v1.Party("/users", myMiddleware)
v1UsersRouter.Get("/", func(ctx iris.Context) {
ctx.HTML("requested: <b>/api/v1/users</b>")
})

// http://localhost:8080/api/v1/users
// http://localhost:8080/api/v1/users?admin=true
app.Run(iris.Addr(":8080"))
}
2 changes: 2 additions & 0 deletions _examples/tutorial/mongodb/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PORT=8080
DSN=mongodb://localhost:27017
Binary file added _examples/tutorial/mongodb/0_create_movie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _examples/tutorial/mongodb/1_update_movie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _examples/tutorial/mongodb/2_get_all_movies.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _examples/tutorial/mongodb/3_get_movie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _examples/tutorial/mongodb/4_delete_movie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions _examples/tutorial/mongodb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Build RESTful API with the official MongoDB Go Driver and Iris

Article is coming soon, follow and stay tuned

- <https://medium.com/@kataras>
- <https://dev.to/kataras>

Read [the fully functional example](main.go).

```sh
$ go get -u github.com/mongodb/mongo-go-driver
$ go get -u github.com/joho/godotenv
```


```sh
# .env file contents
PORT=8080
DSN=mongodb://localhost:27017
```

```sh
$ go run main.go
> 2019/01/28 05:17:59 Loading environment variables from file: .env
> 2019/01/28 05:17:59 ◽ PORT=8080
> 2019/01/28 05:17:59 ◽ DSN=mongodb://localhost:27017
> Now listening on: http://localhost:8080
```

```sh
GET : http://localhost:8080/api/store/movies
POST : http://localhost:8080/api/store/movies
GET : http://localhost:8080/api/store/movies/{id}
PUT : http://localhost:8080/api/store/movies/{id}
DELETE : http://localhost:8080/api/store/movies/{id}
```

## Screens

### Add a Movie
![](0_create_movie.png)

### Update a Movie

![](1_update_movie.png)

### Get all Movies

![](2_get_all_movies.png)

### Get a Movie by its ID

![](3_get_movie.png)

### Delete a Movie by its ID

![](4_delete_movie.png)

101 changes: 101 additions & 0 deletions _examples/tutorial/mongodb/api/store/movie.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package storeapi

import (
"github.com/kataras/iris/_examples/tutorial/mongodb/httputil"
"github.com/kataras/iris/_examples/tutorial/mongodb/store"

"github.com/kataras/iris"
)

type MovieHandler struct {
service store.MovieService
}

func NewMovieHandler(service store.MovieService) *MovieHandler {
return &MovieHandler{service: service}
}

func (h *MovieHandler) GetAll(ctx iris.Context) {
movies, err := h.service.GetAll(nil)
if err != nil {
httputil.InternalServerErrorJSON(ctx, err, "Server was unable to retrieve all movies")
return
}

if movies == nil {
// will return "null" if empty, with this "trick" we return "[]" json.
movies = make([]store.Movie, 0)
}

ctx.JSON(movies)
}

func (h *MovieHandler) Get(ctx iris.Context) {
id := ctx.Params().Get("id")

m, err := h.service.GetByID(nil, id)
if err != nil {
if err == store.ErrNotFound {
ctx.NotFound()
} else {
httputil.InternalServerErrorJSON(ctx, err, "Server was unable to retrieve movie [%s]", id)
}
return
}

ctx.JSON(m)
}

func (h *MovieHandler) Add(ctx iris.Context) {
m := new(store.Movie)

err := ctx.ReadJSON(m)
if err != nil {
httputil.FailJSON(ctx, iris.StatusBadRequest, err, "Malformed request payload")
return
}

err = h.service.Create(nil, m)
if err != nil {
httputil.InternalServerErrorJSON(ctx, err, "Server was unable to create a movie")
return
}

ctx.StatusCode(iris.StatusCreated)
ctx.JSON(m)
}

func (h *MovieHandler) Update(ctx iris.Context) {
id := ctx.Params().Get("id")

var m store.Movie
err := ctx.ReadJSON(&m)
if err != nil {
httputil.FailJSON(ctx, iris.StatusBadRequest, err, "Malformed request payload")
return
}

err = h.service.Update(nil, id, m)
if err != nil {
if err == store.ErrNotFound {
ctx.NotFound()
return
}
httputil.InternalServerErrorJSON(ctx, err, "Server was unable to update movie [%s]", id)
return
}
}

func (h *MovieHandler) Delete(ctx iris.Context) {
id := ctx.Params().Get("id")

err := h.service.Delete(nil, id)
if err != nil {
if err == store.ErrNotFound {
ctx.NotFound()
return
}
httputil.InternalServerErrorJSON(ctx, err, "Server was unable to delete movie [%s]", id)
return
}
}
71 changes: 71 additions & 0 deletions _examples/tutorial/mongodb/env/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package env

import (
"fmt"
"log"
"os"
"path/filepath"
"strings"

"github.com/joho/godotenv"
)

var (
// Port is the PORT environment variable or 8080 if missing.
// Used to open the tcp listener for our web server.
Port string
// DSN is the DSN environment variable or mongodb://localhost:27017 if missing.
// Used to connect to the mongodb.
DSN string
)

func parse() {
Port = getDefault("PORT", "8080")
DSN = getDefault("DSN", "mongodb://localhost:27017")
}

// Load loads environment variables that are being used across the whole app.
// Loading from file(s), i.e .env or dev.env
//
// Example of a 'dev.env':
// PORT=8080
// DSN=mongodb://localhost:27017
//
// After `Load` the callers can get an environment variable via `os.Getenv`.
func Load(envFileName string) {
if args := os.Args; len(args) > 1 && args[1] == "help" {
fmt.Fprintln(os.Stderr, "https://github.com/kataras/iris/blob/master/_examples/tutorials/mongodb/README.md")
os.Exit(-1)
}

log.Printf("Loading environment variables from file: %s\n", envFileName)
// If more than one filename passed with comma separated then load from all
// of these, a env file can be a partial too.
envFiles := strings.Split(envFileName, ",")
for i := range envFiles {
if filepath.Ext(envFiles[i]) == "" {
envFiles[i] += ".env"
}
}

if err := godotenv.Load(envFiles...); err != nil {
panic(fmt.Sprintf("error loading environment variables from [%s]: %v", envFileName, err))
}

envMap, _ := godotenv.Read(envFiles...)
for k, v := range envMap {
log.Printf("◽ %s=%s\n", k, v)
}

parse()
}

func getDefault(key string, def string) string {
value := os.Getenv(key)
if value == "" {
os.Setenv(key, def)
value = def
}

return value
}
Loading