mirror of
https://github.com/kataras/iris.git
synced 2026-01-25 12:55:57 +00:00
ok almost finished. We're good at deadlines eventually. Tomorrow at 23:59 an article will be published same time with the dev branch merge to master
Former-commit-id: 42c1bf88cedbddf3cc01366ab769139546902e71
This commit is contained in:
160
HISTORY.md
160
HISTORY.md
@@ -16,19 +16,161 @@ Developers are not forced to upgrade if they don't really need it. Upgrade whene
|
||||
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
|
||||
|
||||
**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.
|
||||
<!--
|
||||
|
||||
# Mo, 01 Jenuary 2018 | v10.0.0
|
||||
|
||||
|
||||
We must thanks [Mrs. Diana](https://www.instagram.com/merry.dii/) for our awesome new [logo](https://iris-go.com/images/logo.svg)!
|
||||
|
||||
You can [contact](mailto:Kovalenkodiana8@gmail.com) her for any design-related enquiries or explore and send a direct message via [instagram](https://www.instagram.com/merry.dii/).
|
||||
|
||||
TODO:
|
||||
<p align="center">
|
||||
<img width="170px" src="https://iris-go.com/images/logo.svg" />
|
||||
</p>
|
||||
|
||||
1. add one more feature, to 'get' auto-created *Route on the mvc by the function name, people need this to change the route's name
|
||||
for reverse routing in the templates, I've already implemented the 'add custom routes' based on any mvc function by its name.
|
||||
At this version we have many internal improvements but just two major changes and one big feature, called **hero**.
|
||||
|
||||
2. list of the changes, we have just one big change,
|
||||
on the mvc re-design but we have some improvements as well
|
||||
I will not list all 70 commits ofc, just the actual changes
|
||||
the end-developer should know. -->
|
||||
> The new version adds 75 plus new commits, read them if you are developing a web framework based on Iris. Why v10? 9 was skipped for undefined reasons.
|
||||
|
||||
## Hero
|
||||
|
||||
The new package [hero](hero) contains features for binding any object or function that `handlers` may use, these are called dependencies. Hero funcs can also return any type of values, these values will be dispatched to the client.
|
||||
|
||||
> You may saw binding before but you didn't have code editor's support, with Iris you get truly safe binding thanks to the new `hero` package. It's also fast, near to raw handlers performance because Iris calculates everything before server ran!
|
||||
|
||||
Below you will see some screenshots we prepared for you in order to be easier to understand:
|
||||
|
||||
### 1. Path Parameters - Built'n Dependencies
|
||||
|
||||

|
||||
|
||||
### 2. Services - Static Dependencies
|
||||
|
||||

|
||||
|
||||
### 3. Per-Request - Dynamic Dependencies
|
||||
|
||||

|
||||
|
||||
`hero funcs` are very easy to understand and when you start using them **you never go back**.
|
||||
|
||||
Examples:
|
||||
|
||||
- [Basic](_examples/hero/basic/main.go)
|
||||
- [Overview](_examples/hero/overview)
|
||||
|
||||
## MVC
|
||||
|
||||
You have to understand the `hero` package in order to use the `mvc`, because `mvc` uses the `hero` internally for the controller's methods you use as routes, the same rules applied to those controller's methods of yours as well.
|
||||
|
||||
With this version you can register **any controller's methods as routes manually**, you can **get a route based on a method name and change its `Name` (useful for reverse routing inside templates)**, you can use any **dependencies** registered from `hero.Register` or `mvc.New(iris.Party).Register` per mvc application or per-controller, **you can still use `BeginRequest` and `EndRequest`**, you can catch **`BeforeActivation(b mvc.BeforeActivation)` to add dependencies per controller and `AfterActivation(a mvc.AfterActivation)` to make any post-validations**, **singleton controllers when no dynamic dependencies are used**, **Websocket controller, as simple as a `websocket.Connection` dependency** and more...
|
||||
|
||||
Examples:
|
||||
|
||||
**If you used MVC before then read very carefully: MVC CONTAINS SOME BREAKING CHANGES BUT YOU CAN DO A LOT MORE AND EVEN FASTER THAN BEFORE**
|
||||
|
||||
**PLEASE READ THE EXAMPLES CAREFULLY, WE'VE MADE THEM FOR YOU**
|
||||
|
||||
Old examples are here as well. Compare the two different versions of each example to understand what you win if you upgrade now.
|
||||
|
||||
| NEW | OLD |
|
||||
| -----------|-------------|
|
||||
| [Hello world](_examples/mvc/hello-world/main.go) | [OLD Hello world](https://github.com/kataras/iris/blob/v8/_examples/mvc/hello-world/main.go) |
|
||||
| [Session Controller](_examples/mvc/session-controller/main.go) | [OLD Session Controller](https://github.com/kataras/iris/blob/v8/_examples/mvc/session-controller/main.go) |
|
||||
| [Overview - Plus Repository and Service layers](_examples/mvc/overview) | [OLD Overview - Plus Repository and Service layers](https://github.com/kataras/iris/tree/v8/_examples/mvc/overview) |
|
||||
| [Login showcase - Plus Repository and Service layers](_examples/mvc/login) | [OLD Login showcase - Plus Repository and Service layers](https://github.com/kataras/iris/tree/v8/_examples/mvc/login) |
|
||||
| [Singleton](_examples/mvc/singleton) | **NEW** |
|
||||
| [Websocket Controller](_examples/mvc/websocket) | **NEW** |
|
||||
| [Vue.js Todo MVC](_examples/tutorial/vuejs-todo-mvc) | **NEW** |
|
||||
|
||||
## context#PostMaxMemory
|
||||
|
||||
Remove the old static variable `context.DefaultMaxMemory` and replace it with the configuration `WithPostMaxMemory`.
|
||||
|
||||
```go
|
||||
// WithPostMaxMemory sets the maximum post data size
|
||||
// that a client can send to the server, this differs
|
||||
// from the overral request body size which can be modified
|
||||
// by the `context#SetMaxRequestBodySize` or `iris#LimitRequestBodySize`.
|
||||
//
|
||||
// Defaults to 32MB or 32 << 20 if you prefer.
|
||||
func WithPostMaxMemory(limit int64) Configurator
|
||||
```
|
||||
|
||||
If you used that old static field you will have to change that single line.
|
||||
|
||||
Usage:
|
||||
|
||||
```go
|
||||
import "github.com/kataras/iris"
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
// [...]
|
||||
|
||||
app.Run(iris.Addr(":8080"), iris.WithPostMaxMemory(10 << 20))
|
||||
}
|
||||
```
|
||||
|
||||
## context#UploadFormFiles
|
||||
|
||||
New method to upload multiple files, should be used for common upload actions, it's just a helper function.
|
||||
|
||||
```go
|
||||
// UploadFormFiles uploads any received file(s) from the client
|
||||
// to the system physical location "destDirectory".
|
||||
//
|
||||
// The second optional argument "before" gives caller the chance to
|
||||
// modify the *miltipart.FileHeader before saving to the disk,
|
||||
// it can be used to change a file's name based on the current request,
|
||||
// all FileHeader's options can be changed. You can ignore it if
|
||||
// you don't need to use this capability before saving a file to the disk.
|
||||
//
|
||||
// Note that it doesn't check if request body streamed.
|
||||
//
|
||||
// Returns the copied length as int64 and
|
||||
// a not nil error if at least one new file
|
||||
// can't be created due to the operating system's permissions or
|
||||
// http.ErrMissingFile if no file received.
|
||||
//
|
||||
// If you want to receive & accept files and manage them manually you can use the `context#FormFile`
|
||||
// instead and create a copy function that suits your needs, the below is for generic usage.
|
||||
//
|
||||
// The default form's memory maximum size is 32MB, it can be changed by the
|
||||
// `iris#WithPostMaxMemory` configurator at main configuration passed on `app.Run`'s second argument.
|
||||
//
|
||||
// See `FormFile` to a more controlled to receive a file.
|
||||
func (ctx *context) UploadFormFiles(
|
||||
destDirectory string,
|
||||
before ...func(string, string),
|
||||
) (int64, error)
|
||||
```
|
||||
|
||||
Example can be found [here](_examples/http_request/upload-files/main.go).
|
||||
|
||||
## context#View
|
||||
|
||||
Just a minor addition, add a second optional variadic argument to the `context#view` method to accept a single value for template binding.
|
||||
When you just want one value and not key-value pairs, you used to use an empty string on the `ViewData`, which is fine, especially if you preload these from a previous handler/middleware in the request handlers chain.
|
||||
|
||||
```go
|
||||
func(ctx iris.Context) {
|
||||
ctx.ViewData("", myItem{Name: "iris" })
|
||||
ctx.View("item.html")
|
||||
}
|
||||
```
|
||||
|
||||
Same as:
|
||||
|
||||
```go
|
||||
func(ctx iris.Context) {
|
||||
ctx.View("item.html", myItem{Name: "iris" })
|
||||
}
|
||||
```
|
||||
|
||||
```html
|
||||
Item's name: {{.Name}}
|
||||
```
|
||||
|
||||
## Session#GetString
|
||||
|
||||
`sessions/session#GetString` can now return a filled value even if the stored value is a type of integer, just like the memstore, the context's temp store, the context's path parameters and the context's url parameters.
|
||||
Reference in New Issue
Block a user