mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
Fix history big mistakes, point links to /v6 tag only https://github.com/kataras/iris/issues/606
Former-commit-id: e0a7ce1a991e5d6600de6cc0a853ef8b1cb8d282
This commit is contained in:
parent
7263649002
commit
f83c7fb4e7
98
HISTORY.md
98
HISTORY.md
|
@ -16,7 +16,7 @@ to adapt the new changes to your application, it contains an overview of the new
|
|||
|
||||
- Router (two lines to add, new features)
|
||||
- Template engines (two lines to add, same features as before, except their easier configuration)
|
||||
- Basic middleware, that have been written by me, are transfared to the main repository[/middleware](https://github.com/kataras/iris/tree/master/middleware) with a lot of improvements to the `recover middleware` (see the next)
|
||||
- Basic middleware, that have been written by me, are transfared to the main repository[/middleware](https://github.com/kataras/iris/tree/v6/middleware) with a lot of improvements to the `recover middleware` (see the next)
|
||||
- `func(http.ResponseWriter, r *http.Request, next http.HandlerFunc)` signature is fully compatible using `iris.ToHandler` helper wrapper func, without any need of custom boilerplate code. So all net/http middleware out there are supported, no need to re-invert the world here, search to the internet and you'll find a suitable to your case.
|
||||
- Developers can use a `yaml` files for the configuration using the `iris.YAML` function: `app := iris.New(iris.YAML("myconfiguration.yaml"))`
|
||||
|
||||
|
@ -42,31 +42,31 @@ Changes:
|
|||
- Remove `.Logger`, `.Config.IsDevelopment`, `.Config.LoggerOut`, `.Config.LoggerPrefix` you can adapt a logger which will log to each log message mode by `app.Adapt(iris.DevLogger())` or adapt a new one, it's just a `func(mode iris.LogMode, message string)`.
|
||||
- Remove `.Config.DisableTemplateEngines`, are disabled by-default, you have to `.Adapt` a view engine by yourself
|
||||
- Remove `context.RenderTemplateSource` you should make a new template file and use the `iris.Render` to specify an `io.Writer` like `bytes.Buffer`
|
||||
- Remove `plugins`, replaced with more pluggable echosystem that I designed from zero on this release, named `Policy` [Adaptors](https://github.com/kataras/iris/tree/master/adaptors) (all plugins have been converted, fixed and improvement, except the iriscontrol).
|
||||
- Remove `plugins`, replaced with more pluggable echosystem that I designed from zero on this release, named `Policy` [Adaptors](https://github.com/kataras/iris/tree/v6/adaptors) (all plugins have been converted, fixed and improvement, except the iriscontrol).
|
||||
- `context.Log(string,...interface{})` -> `context.Log(iris.LogMode, string)`
|
||||
- Remove `.Config.DisableBanner`, now it's controlled by `app.Adapt(iris.LoggerPolicy(func(mode iris.LogMode, msg string)))`
|
||||
- Remove `.Config.Websocket` , replaced with the `kataras/iris/adaptors/websocket.Config` adaptor.
|
||||
|
||||
- https://github.com/iris-contrib/plugin -> https://github.com/iris-contrib/adaptors
|
||||
|
||||
- `import "github.com/iris-contrib/middleware/basicauth"` -> `import "github.com/kataras/iris/middleware/basicauth"`
|
||||
- `import "github.com/iris-contrib/middleware/i18n"` -> `import "github.com/kataras/iris/middleware/i18n"`
|
||||
- `import "github.com/iris-contrib/middleware/logger"` -> `import "github.com/kataras/iris/middleware/logger"`
|
||||
- `import "github.com/iris-contrib/middleware/recovery"` -> `import "github.com/kataras/iris/middleware/recover"`
|
||||
- `import "github.com/iris-contrib/middleware/basicauth"` -> `import "gopkg.in/kataras/iris.v6/middleware/basicauth"`
|
||||
- `import "github.com/iris-contrib/middleware/i18n"` -> `import "gopkg.in/kataras/iris.v6/middleware/i18n"`
|
||||
- `import "github.com/iris-contrib/middleware/logger"` -> `import "gopkg.in/kataras/iris.v6/middleware/logger"`
|
||||
- `import "github.com/iris-contrib/middleware/recovery"` -> `import "gopkg.in/kataras/iris.v6/middleware/recover"`
|
||||
|
||||
|
||||
- `import "github.com/iris-contrib/plugin/typescript"` -> `import "github.com/kataras/iris/adaptors/typescript"`
|
||||
- `import "github.com/iris-contrib/plugin/editor"` -> `import "github.com/kataras/iris/adaptors/typescript/editor"`
|
||||
- `import "github.com/iris-contrib/plugin/cors"` -> `import "github.com/kataras/iris/adaptors/cors"`
|
||||
- `import "github.com/iris-contrib/plugin/gorillamux"` -> `import "github.com/kataras/iris/adaptors/gorillamux"`
|
||||
- `import "github.com/iris-contrib/plugin/typescript"` -> `import "gopkg.in/kataras/iris.v6/adaptors/typescript"`
|
||||
- `import "github.com/iris-contrib/plugin/editor"` -> `import "gopkg.in/kataras/iris.v6/adaptors/typescript/editor"`
|
||||
- `import "github.com/iris-contrib/plugin/cors"` -> `import "gopkg.in/kataras/iris.v6/adaptors/cors"`
|
||||
- `import "github.com/iris-contrib/plugin/gorillamux"` -> `import "gopkg.in/kataras/iris.v6/adaptors/gorillamux"`
|
||||
- `import github.com/iris-contrib/plugin/oauth"` -> `import "github.com/iris-contrib/adaptors/oauth"`
|
||||
|
||||
|
||||
- `import "github.com/kataras/go-template/html"` -> `import "github.com/kataras/iris/adaptors/view"`
|
||||
- `import "github.com/kataras/go-template/django"` -> `import "github.com/kataras/iris/adaptors/view"`
|
||||
- `import "github.com/kataras/go-template/pug"` -> `import "github.com/kataras/iris/adaptors/view"`
|
||||
- `import "github.com/kataras/go-template/handlebars"` -> `import "github.com/kataras/iris/adaptors/view"`
|
||||
- `import "github.com/kataras/go-template/amber"` -> `import "github.com/kataras/iris/adaptors/view"`
|
||||
- `import "github.com/kataras/go-template/html"` -> `import "gopkg.in/kataras/iris.v6/adaptors/view"`
|
||||
- `import "github.com/kataras/go-template/django"` -> `import "gopkg.in/kataras/iris.v6/adaptors/view"`
|
||||
- `import "github.com/kataras/go-template/pug"` -> `import "gopkg.in/kataras/iris.v6/adaptors/view"`
|
||||
- `import "github.com/kataras/go-template/handlebars"` -> `import "gopkg.in/kataras/iris.v6/adaptors/view"`
|
||||
- `import "github.com/kataras/go-template/amber"` -> `import "gopkg.in/kataras/iris.v6/adaptors/view"`
|
||||
|
||||
**Read more below** for the lines you have to change. Package-level removal is critical, you will have build-time errors. Router(less) is MUST, otherwise your app will fatal with a detailed error message.
|
||||
|
||||
|
@ -88,7 +88,7 @@ At the past I gave you many workarounds, but they are just workarounds, not a co
|
|||
Two routers available to use, today:
|
||||
|
||||
|
||||
- [httprouter](https://github.com/kataras/iris/tree/master/adaptors/httprouter), the old defaulted. A router that can be adapted, it's a custom version of https://github.comjulienschmidt/httprouter which is edited to support iris' subdomains, reverse routing, custom http errors and a lot features, it should be a bit faster than the original too because of iris' Context. It uses `/mypath/:firstParameter/path/:secondParameter` and `/mypath/*wildcardParamName` .
|
||||
- [httprouter](https://github.com/kataras/iris/tree/v6/adaptors/httprouter), the old defaulted. A router that can be adapted, it's a custom version of https://github.comjulienschmidt/httprouter which is edited to support iris' subdomains, reverse routing, custom http errors and a lot features, it should be a bit faster than the original too because of iris' Context. It uses `/mypath/:firstParameter/path/:secondParameter` and `/mypath/*wildcardParamName` .
|
||||
|
||||
|
||||
Example:
|
||||
|
@ -97,8 +97,8 @@ Example:
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/adaptors/httprouter" // <---- NEW
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/httprouter" // <---- NEW
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -184,7 +184,7 @@ func h(ctx *iris.Context) {
|
|||
|
||||
```
|
||||
|
||||
- [gorillamux](https://github.com/kataras/iris/tree/master/adaptors/gorillamux), a router that can be adapted, it's the https://github.com/gorilla/mux which supports subdomains, custom http errors, reverse routing, pattern matching via regex and the rest of the iris' features.
|
||||
- [gorillamux](https://github.com/kataras/iris/tree/v6/adaptors/gorillamux), a router that can be adapted, it's the https://github.com/gorilla/mux which supports subdomains, custom http errors, reverse routing, pattern matching via regex and the rest of the iris' features.
|
||||
|
||||
|
||||
Example:
|
||||
|
@ -193,8 +193,8 @@ Example:
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/adaptors/gorillamux" // <---- NEW
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/gorillamux" // <---- NEW
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -296,7 +296,7 @@ As we said, all iris' features works as before even if you are able to adapt any
|
|||
> I would love to see more routers (as more as they can provide different `path declaration` features) from the community, create an adaptor for an iris' router and I will share your repository to the rest of the users!
|
||||
|
||||
|
||||
Adaptors are located [there](https://github.com/kataras/iris/tree/master/adaptors).
|
||||
Adaptors are located [there](https://github.com/kataras/iris/tree/v6/adaptors).
|
||||
|
||||
### View engine (5 template engine adaptors)
|
||||
|
||||
|
@ -320,7 +320,7 @@ All of these **five template engines** have common features with common API, lik
|
|||
|
||||
- **amber**, based on [go-template/amber](https://github.com/kataras/go-template/tree/master/amber), its template parser is the [amber](https://github.com/eknkc/amber).
|
||||
|
||||
Each of the template engines has different options, view adaptors are located [here](https://github.com/kataras/iris/tree/master/adaptors/view).
|
||||
Each of the template engines has different options, view adaptors are located [here](https://github.com/kataras/iris/tree/v6/adaptors/view).
|
||||
|
||||
|
||||
Example:
|
||||
|
@ -330,9 +330,9 @@ Example:
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/adaptors/gorillamux" // <--- NEW (previous section)
|
||||
"github.com/kataras/iris/adaptors/view" // <--- NEW it contains all the template engines
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/gorillamux" // <--- NEW (previous section)
|
||||
"gopkg.in/kataras/iris.v6/adaptors/view" // <--- NEW it contains all the template engines
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -390,7 +390,7 @@ app.UseTemplate(django.New()).Directory("./templates", ".html")/*.Binary(...)*/)
|
|||
|
||||
**AFTER**
|
||||
```go
|
||||
import "github.com/kataras/iris/adaptors/view"
|
||||
import ""gopkg.in/kataras/iris.v6/adaptors/view"
|
||||
// ...
|
||||
app := iris.New()
|
||||
app.Adapt(view.Django("./templates",".htmll")/*.Binary(...)*/)
|
||||
|
@ -485,8 +485,8 @@ func main(){
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/adaptors/httprouter"
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/httprouter"
|
||||
)
|
||||
|
||||
func init(){
|
||||
|
@ -501,7 +501,7 @@ func init(){
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
_ "github.com/mypackage/controllers"
|
||||
)
|
||||
|
||||
|
@ -588,8 +588,8 @@ func main() {
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/adaptors/gorillamux"
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/gorillamux"
|
||||
)
|
||||
|
||||
func GetAllUsersHandler(ctx *iris.Context) {
|
||||
|
@ -773,11 +773,11 @@ We have 8 policies, so far, and some of them have 'subpolicies' (the RouterRever
|
|||
- SessionsPolicy
|
||||
|
||||
|
||||
**Details** of these can be found at [policy.go](https://github.com/kataras/iris/blob/master/policy.go).
|
||||
**Details** of these can be found at [policy.go](https://github.com/kataras/iris/blob/v6/policy.go).
|
||||
|
||||
The **Community**'s adaptors are [here](https://github.com/iris-contrib/adaptors).
|
||||
|
||||
**Iris' Built'n Adaptors** for these policies can be found at [/adaptors folder](https://github.com/kataras/iris/tree/master/adaptors).
|
||||
**Iris' Built'n Adaptors** for these policies can be found at [/adaptors folder](https://github.com/kataras/iris/tree/v6/adaptors).
|
||||
|
||||
The folder contains:
|
||||
|
||||
|
@ -825,8 +825,8 @@ Example:
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/adaptors/gorillamux"
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/gorillamux"
|
||||
"github.com/rs/cors"
|
||||
)
|
||||
|
||||
|
@ -856,7 +856,7 @@ func main(){
|
|||
|
||||
### iris cmd
|
||||
|
||||
- FIX: [iris run main.go](https://github.com/kataras/iris/tree/master/iris#run) not reloading when file changes maden by some of the IDEs,
|
||||
- FIX: [iris run main.go](https://github.com/kataras/iris/tree/v6/iris#run) not reloading when file changes maden by some of the IDEs,
|
||||
because they do override the operating system's fs signals. The majority of
|
||||
editors worked before but I couldn't let some developers without support.
|
||||
|
||||
|
@ -886,7 +886,7 @@ to adapt a package as a session manager. So `iris.UseDatabase` has been removed
|
|||
|
||||
> Don't worry about forgetting to adapt any feature that you use inside Iris, Iris will print you a how-to-fix message at iris.DevMode log level.
|
||||
|
||||
**[Example](https://github.com/kataras/iris/tree/6.2/adaptors/sessions/_example) code:**
|
||||
**[Example](https://github.com/kataras/iris/tree/v6/adaptors/sessions/_example) code:**
|
||||
|
||||
```go
|
||||
package main
|
||||
|
@ -989,7 +989,7 @@ Websocket is an Adaptor too and you can edit more configuration fields than befo
|
|||
No Write and Read timeout by default, you have to set the fields if you want to enable timeout.
|
||||
|
||||
Below you'll see the before and the after, keep note that the static and templates didn't changed, so I am not putting the whole
|
||||
html and javascript sources here, you can run the full examples from [here](https://github.com/kataras/iris/tree/6.2/adaptors/websocket/_examples).
|
||||
html and javascript sources here, you can run the full examples from [here](https://github.com/kataras/iris/tree/v6/adaptors/websocket/_examples).
|
||||
|
||||
**BEFORE:***
|
||||
|
||||
|
@ -1190,8 +1190,8 @@ package main
|
|||
import (
|
||||
"log"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/adaptors/httprouter"
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/httprouter"
|
||||
"github.com/googollee/go-socket.io"
|
||||
)
|
||||
|
||||
|
@ -1226,12 +1226,12 @@ func main() {
|
|||
### Typescript compiler and cloud-based editor
|
||||
|
||||
The Typescript compiler adaptor(old 'plugin') has been fixed (it had an issue on new typescript versions).
|
||||
Example can be bound [here](https://github.com/kataras/iris/tree/master/adaptors/typescript/_example).
|
||||
Example can be bound [here](https://github.com/kataras/iris/tree/v6/adaptors/typescript/_example).
|
||||
|
||||
The Cloud-based editor adaptor(old 'plugin') also fixed and improved to show debug messages to your iris' LoggerPolicy.
|
||||
Example can be bound [here](https://github.com/kataras/iris/tree/master/adaptors/typescript/editor/_example).
|
||||
Example can be bound [here](https://github.com/kataras/iris/tree/v6/adaptors/typescript/editor/_example).
|
||||
|
||||
Their import paths also changed as the rest of the old plugins from: https://github.com/iris-contrib/plugin to https://github.com/kataras/adaptors.
|
||||
Their import paths also changed as the rest of the old plugins from: https://github.com/iris-contrib/plugin to https://github.com/kataras/adaptors and https://github.com/iris-contrib/adaptors
|
||||
I had them on iris-contrib because I thought that community would help but it didn't, no problem, they are at the same codebase now
|
||||
which making things easier to debug for me.
|
||||
|
||||
|
@ -1260,8 +1260,8 @@ Example:
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/adaptors/gorillamux"
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/gorillamux"
|
||||
"github.com/rs/cors"
|
||||
)
|
||||
|
||||
|
@ -1290,9 +1290,9 @@ Example:
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/adaptors/httprouter"
|
||||
"github.com/kataras/adaptors/cors"
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/httprouter"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/cors"
|
||||
)
|
||||
|
||||
func main(){
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
## Package information
|
||||
|
||||
Gorillamux is a plugin for Iris which overrides the Iris' default router with the [Gorilla Mux](https://github.com/gorilla/mux)
|
||||
which enables path matching using custom `regexp` ( thing that the Iris' default router doesn't supports for performance reasons).
|
||||
|
||||
All these without need to change any of your existing Iris code. All features are supported.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ go get -u github.com/iris-contrib/plugin/gorillamux
|
||||
```
|
||||
|
||||
|
||||
```go
|
||||
iris.Plugins.Add(gorillamux.New())
|
||||
```
|
||||
|
||||
## [Example](https://github.com/iris-contrib/examples/tree/master/plugin_gorillamux)
|
||||
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/iris-contrib/plugin/gorillamux"
|
||||
"github.com/kataras/iris"
|
||||
)
|
||||
|
||||
func main() {
|
||||
iris.Plugins.Add(gorillamux.New())
|
||||
|
||||
// CUSTOM HTTP ERRORS ARE SUPPORTED
|
||||
// NOTE: Gorilla mux allows customization only on StatusNotFound(404)
|
||||
// Iris allows for everything, so you can register any other custom http error
|
||||
// but you have to call it manually from ctx.EmitError(status_code) // 500 for example
|
||||
// this will work because it's StatusNotFound:
|
||||
iris.Default.OnError(iris.StatusNotFound, func(ctx *iris.Context) {
|
||||
ctx.HTML(iris.StatusNotFound, "<h1> CUSTOM NOT FOUND ERROR PAGE </h1>")
|
||||
})
|
||||
|
||||
// GLOBAL/PARTY MIDDLEWARE ARE SUPPORTED
|
||||
iris.Default.UseFunc(func(ctx *iris.Context) {
|
||||
println("Request: " + ctx.Path())
|
||||
ctx.Next()
|
||||
})
|
||||
|
||||
// http://mydomain.com
|
||||
iris.Default.Get("/", func(ctx *iris.Context) {
|
||||
ctx.Writef("Hello from index")
|
||||
})
|
||||
|
||||
/// -------------------------------------- IMPORTANT --------------------------------------
|
||||
/// GORILLA MUX PARAMETERS(regexp) ARE SUPPORTED
|
||||
/// http://mydomain.com/api/users/42
|
||||
/// ---------------------------------------------------------------------------------------
|
||||
iris.Default.Get("/api/users/{userid:[0-9]+}", func(ctx *iris.Context) {
|
||||
ctx.Writef("User with id: %s", ctx.Param("userid"))
|
||||
})
|
||||
|
||||
// PER-ROUTE MIDDLEWARE ARE SUPPORTED
|
||||
// http://mydomain.com/other
|
||||
iris.Default.Get("/other", func(ctx *iris.Context) {
|
||||
ctx.Writef("/other 1 middleware \n")
|
||||
ctx.Next()
|
||||
}, func(ctx *iris.Context) {
|
||||
ctx.HTML(iris.StatusOK, "<b>Hello from /other</b>")
|
||||
})
|
||||
|
||||
// SUBDOMAINS ARE SUPPORTED
|
||||
// http://admin.mydomain.com
|
||||
iris.Default.Party("admin.").Get("/", func(ctx *iris.Context) {
|
||||
ctx.Writef("Hello from admin. subdomain!")
|
||||
})
|
||||
|
||||
// WILDCARD SUBDOMAINS ARE SUPPORTED
|
||||
// http://api.mydomain.com/hi
|
||||
// http://admin.mydomain.com/hi
|
||||
// http://x.mydomain.com/hi
|
||||
// [depends on your host configuration,
|
||||
// you will see an example(win) outside of this folder].
|
||||
iris.Default.Party("*.").Get("/hi", func(ctx *iris.Context) {
|
||||
ctx.Writef("Hello from wildcard subdomain: %s", ctx.Subdomain())
|
||||
})
|
||||
|
||||
// DOMAIN NAMING IS SUPPORTED
|
||||
iris.Default.Listen("mydomain.com")
|
||||
// iris.Default.Listen(":80")
|
||||
}
|
||||
|
||||
/* HOSTS FILE LINES TO RUN THIS EXAMPLE:
|
||||
|
||||
127.0.0.1 mydomain.com
|
||||
127.0.0.1 admin.mydomain.com
|
||||
127.0.0.1 api.mydomain.com
|
||||
127.0.0.1 x.mydomain.com
|
||||
|
||||
*/
|
||||
|
||||
|
||||
```
|
||||
|
||||
> Custom domain is totally optionally, you can still use `iris.Default.Listen(":8080")` of course.
|
|
@ -1,89 +0,0 @@
|
|||
## Package information
|
||||
|
||||
This is an Iris and typescript bridge plugin.
|
||||
|
||||
1. Search for typescript files (.ts)
|
||||
2. Search for typescript projects (.tsconfig)
|
||||
3. If 1 || 2 continue else stop
|
||||
4. Check if typescript is installed, if not then auto-install it (always inside npm global modules, -g)
|
||||
5. If typescript project then build the project using tsc -p $dir
|
||||
6. If typescript files and no project then build each typescript using tsc $filename
|
||||
7. Watch typescript files if any changes happens, then re-build (5|6)
|
||||
|
||||
> Note: Ignore all typescript files & projects whose path has '/node_modules/'
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ go get -u github.com/iris-contrib/plugin/typescript
|
||||
```
|
||||
|
||||
|
||||
## Options
|
||||
|
||||
This plugin has **optionally** options
|
||||
1. Bin: string, the typescript installation path/bin/tsc or tsc.cmd, if empty then it will search to the global npm modules
|
||||
2. Dir: string, Dir set the root, where to search for typescript files/project. Default "./"
|
||||
3. Ignore: string, comma separated ignore typescript files/project from these directories. Default "" (node_modules are always ignored)
|
||||
4. Tsconfig: &typescript.Tsconfig{}, here you can set all compilerOptions if no tsconfig.json exists inside the 'Dir'
|
||||
5. Editor: typescript.Editor(), if setted then alm-tools browser-based typescript IDE will be available. Defailt is nil
|
||||
|
||||
> Note: if any string in Ignore doesn't start with './' then it will ignore all files which contains this path string.
|
||||
For example /node_modules/ will ignore all typescript files that are inside at ANY '/node_modules/', that means and the submodules.
|
||||
|
||||
|
||||
## How to use
|
||||
|
||||
```go
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/iris-contrib/plugin/typescript"
|
||||
)
|
||||
|
||||
func main(){
|
||||
/* Options
|
||||
Bin -> the typescript installation path/bin/tsc or tsc.cmd, if empty then it will search to the global npm modules
|
||||
Dir -> where to search for typescript files/project. Default "./"
|
||||
Ignore -> comma separated ignore typescript files/project from these directories (/node_modules/ are always ignored). Default ""
|
||||
Tsconfig -> &typescript.Tsconfig{}, here you can set all compilerOptions if no tsconfig.json exists inside the 'Dir'
|
||||
Editor -> typescript.Editor(), if setted then alm-tools browser-based typescript IDE will be available. Default is nil.
|
||||
*/
|
||||
|
||||
config := typescript.Config {
|
||||
Dir: "./scripts/src",
|
||||
Tsconfig: &typescript.Tsconfig{Module: "commonjs", Target: "es5"}, // or typescript.DefaultTsconfig()
|
||||
}
|
||||
|
||||
//if you want to change only certain option(s) but you want default to all others then you have to do this:
|
||||
config = typescript.DefaultConfig()
|
||||
//
|
||||
|
||||
iris.Plugins.Add(typescript.New(config)) //or with the default options just: typescript.New()
|
||||
|
||||
iris.Default.Get("/", func (ctx *iris.Context){})
|
||||
|
||||
iris.Default.Listen(":8080")
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Editor
|
||||
|
||||
[alm-tools](http://alm.tools) is a typescript online IDE/Editor, made by [@basarat](https://twitter.com/basarat) one of the top contributors of the [Typescript](http://www.typescriptlang.org).
|
||||
|
||||
Iris gives you the opportunity to edit your client-side using the alm-tools editor, via the editor plugin.
|
||||
With typescript plugin you have to set the Editor option and you're ready:
|
||||
|
||||
```go
|
||||
typescript.Config {
|
||||
//...
|
||||
Editor: typescript.Editor("username","passowrd")
|
||||
//...
|
||||
}
|
||||
```
|
||||
|
||||
> [Read more](https://github.com/kataras/iris/tree/development/plugin/editor) for Editor
|
|
@ -1502,9 +1502,9 @@ Edit your main .go source file to adapt one of these and restart your app.
|
|||
i.e: lines (<---) were missing.
|
||||
-------------------------------------------------------------------
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/adaptors/httprouter" // or gorillamux
|
||||
"github.com/kataras/iris/adaptors/sessions" // <--- this line
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/httprouter" // or gorillamux
|
||||
"gopkg.in/kataras/iris.v6/adaptors/sessions" // <--- this line
|
||||
)
|
||||
|
||||
func main(){
|
||||
|
|
6
iris.go
6
iris.go
|
@ -848,9 +848,9 @@ Edit your main .go source file to adapt one of these and restart your app.
|
|||
i.e: lines (<---) were missing.
|
||||
-------------------------------------------------------------------
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/adaptors/httprouter" // or gorillamux
|
||||
"github.com/kataras/iris/adaptors/view" // <--- this line
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/httprouter" // or gorillamux
|
||||
"gopkg.in/kataras/iris.v6/adaptors/view" // <--- this line
|
||||
)
|
||||
|
||||
func main(){
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
## Middleware information
|
||||
|
||||
This folder contains a middleware for internationalization uses a third-party package named i81n.
|
||||
|
||||
More can be found here:
|
||||
[https://github.com/Unknwon/i18n](https://github.com/Unknwon/i18n)
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ go get -u github.com/iris-contrib/middleware/i18n
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Package i18n is for app Internationalization and Localization.
|
||||
|
||||
|
||||
## How to use
|
||||
|
||||
Create folder named 'locales'
|
||||
```
|
||||
///Files:
|
||||
|
||||
./locales/locale_en-US.ini
|
||||
./locales/locale_el-US.ini
|
||||
```
|
||||
Contents on locale_en-US:
|
||||
```
|
||||
hi = hello, %s
|
||||
```
|
||||
Contents on locale_el-GR:
|
||||
```
|
||||
hi = <20><><EFBFBD><EFBFBD>, %s
|
||||
```
|
||||
|
||||
```go
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/iris-contrib/middleware/i18n"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
iris.UseFunc(i18n.New(i18n.Config{Default: "en-US",
|
||||
Languages: map[string]string{
|
||||
"en-US": "./locales/locale_en-US.ini",
|
||||
"el-GR": "./locales/locale_el-GR.ini",
|
||||
"zh-CN": "./locales/locale_zh-CN.ini"}}))
|
||||
// or iris.Use(i18n.I18nHandler(....))
|
||||
// or iris.Get("/",i18n.I18n(....), func (ctx *iris.Context){})
|
||||
|
||||
iris.Get("/", func(ctx *iris.Context) {
|
||||
hi := ctx.GetFmt("translate")("hi", "maki") // hi is the key, 'maki' is the %s, the second parameter is optional
|
||||
language := ctx.Get("language") // language is the language key, example 'en-US'
|
||||
|
||||
ctx.Write("From the language %s translated output: %s", language, hi)
|
||||
})
|
||||
|
||||
iris.Listen(":8080")
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### [For a working example, click here](https://github.com/kataras/iris/tree/examples/middleware_internationalization_i18n)
|
|
@ -71,8 +71,8 @@ Edit your main .go source file to adapt one of these routers and restart your ap
|
|||
i.e: lines (<---) were missing.
|
||||
----------------------------HTTPROUTER----------------------------------
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/adaptors/httprouter" // <--- this line
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/httprouter" // <--- this line
|
||||
)
|
||||
|
||||
func main(){
|
||||
|
@ -90,8 +90,8 @@ Edit your main .go source file to adapt one of these routers and restart your ap
|
|||
----------------------------OR GORILLA MUX-------------------------------
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/adaptors/gorillamux" // <--- or this line
|
||||
"gopkg.in/kataras/iris.v6"
|
||||
"gopkg.in/kataras/iris.v6/adaptors/gorillamux" // <--- or this line
|
||||
)
|
||||
|
||||
func main(){
|
||||
|
|
Loading…
Reference in New Issue
Block a user