add h2 header manually for pre-go 1.9 users when manually key files are being used

Former-commit-id: edf521fc02de87b53cd3bdf0b8e77610dd535862
This commit is contained in:
kataras 2017-09-05 14:47:41 +03:00
parent bd779117fe
commit fcfc65a7bc
6 changed files with 130 additions and 29 deletions

View File

@ -41,36 +41,36 @@ Iris may have reached version 8, but we're not stopping there. We have many feat
* [Latest changes](https://github.com/kataras/iris/blob/master/HISTORY.md#su-27-august-2017--v840) * [Latest changes](https://github.com/kataras/iris/blob/master/HISTORY.md#su-27-august-2017--v840)
* [Learn](#-learn) * [Learn](#-learn)
* [HTTP Listening](_examples/#http-listening) * [HTTP Listening](_examples/#http-listening)
* [Configuration](_examples/#configuration) * [Configuration](_examples/#configuration)
* [Routing, Grouping, Dynamic Path Parameters, "Macros" and Custom Context](_examples/#routing-grouping-dynamic-path-parameters-macros-and-custom-context) * [Routing, Grouping, Dynamic Path Parameters, "Macros" and Custom Context](_examples/#routing-grouping-dynamic-path-parameters-macros-and-custom-context)
* [MVC (Model View Controller)](_examples/#mvc) **NEW** * [MVC (Model View Controller)](_examples/#mvc) **NEW**
* [Subdomains](_examples/#subdomains) * [Subdomains](_examples/#subdomains)
* [Wrap `http.Handler/HandlerFunc`](_examples/#convert-httphandlerhandlerfunc) * [Wrap `http.Handler/HandlerFunc`](_examples/#convert-httphandlerhandlerfunc)
* [View](_examples/#view) * [View](_examples/#view)
* [Authentication](_examples/#authentication) * [Authentication](_examples/#authentication)
* [File Server](_examples/#file-server) * [File Server](_examples/#file-server)
* [How to Read from `context.Request() *http.Request`](_examples/#how-to-read-from-contextrequest-httprequest) * [How to Read from `context.Request() *http.Request`](_examples/#how-to-read-from-contextrequest-httprequest)
* [How to Write to `context.ResponseWriter() http.ResponseWriter`](_examples/#how-to-write-to-contextresponsewriter-httpresponsewriter) * [How to Write to `context.ResponseWriter() http.ResponseWriter`](_examples/#how-to-write-to-contextresponsewriter-httpresponsewriter)
* [Test](_examples/#testing) * [Test](_examples/#testing)
* [Cache](_examples/#caching) * [Cache](_examples/#caching)
* [Sessions](_examples/#sessions) * [Sessions](_examples/#sessions)
* [Websockets](_examples/#websockets) * [Websockets](_examples/#websockets)
* [Miscellaneous](_examples/#miscellaneous) * [Miscellaneous](_examples/#miscellaneous)
* [POC: Convert the medium-sized project "Parrot" from native to Iris](https://github.com/iris-contrib/parrot) * [POC: Convert the medium-sized project "Parrot" from native to Iris](https://github.com/iris-contrib/parrot)
* [Typescript Automation Tools](typescript/#table-of-contents) * [Typescript Automation Tools](typescript/#table-of-contents)
* [Tutorial: Online Visitors](_examples/tutorial/online-visitors) * [Tutorial: Online Visitors](_examples/tutorial/online-visitors)
* [Tutorial: Caddy](_examples/tutorial/caddy) * [Tutorial: Caddy](_examples/tutorial/caddy)
* [Middleware](middleware/) * [Middleware](middleware/)
* [Dockerize](https://github.com/iris-contrib/cloud-native-go) * [Dockerize](https://github.com/iris-contrib/cloud-native-go)
* [Community & Support](#-community) * [Community & Support](#-community)
* [Blogs](https://iris-go.com/v8/blogs) * [Blogs](https://iris-go.com/v8/blogs)
- [Iris Go vs .NET Core Kestrel in terms of HTTP performance](https://hackernoon.com/iris-go-vs-net-core-kestrel-in-terms-of-http-performance-806195dc93d5) - [Iris Go vs .NET Core Kestrel in terms of HTTP performance](https://hackernoon.com/iris-go-vs-net-core-kestrel-in-terms-of-http-performance-806195dc93d5)
- [Go vs .NET Core in terms of HTTP performance](https://medium.com/@kataras/go-vs-net-core-in-terms-of-http-performance-7535a61b67b8) - [Go vs .NET Core in terms of HTTP performance](https://medium.com/@kataras/go-vs-net-core-in-terms-of-http-performance-7535a61b67b8)
- [Iris, a modular web framework](https://medium.com/@corebreaker/iris-web-cd684b4685c7) - [Iris, a modular web framework](https://medium.com/@corebreaker/iris-web-cd684b4685c7)
- [Deploying a Iris Golang app in hasura](https://docs.hasura.io/0.14/tutorials/deploying-a-go-iris-app.html) - [Deploying a Iris Golang app in hasura](https://docs.hasura.io/0.14/tutorials/deploying-a-go-iris-app.html)
- [How to Turn an Android Device into a Web Server](https://twitter.com/ThePracticalDev/status/892022594031017988) - [How to Turn an Android Device into a Web Server](https://twitter.com/ThePracticalDev/status/892022594031017988)
- [A URL Shortener Service using Go, Iris and Bolt](https://medium.com/@kataras/a-url-shortener-service-using-go-iris-and-bolt-4182f0b00ae7) - [A URL Shortener Service using Go, Iris and Bolt](https://medium.com/@kataras/a-url-shortener-service-using-go-iris-and-bolt-4182f0b00ae7)
- [Why I preferred Go over Node.js for simple Web Application](https://medium.com/@tigranbs/why-i-preferred-go-over-node-js-for-simple-web-application-d4a549e979b9) - [Why I preferred Go over Node.js for simple Web Application](https://medium.com/@tigranbs/why-i-preferred-go-over-node-js-for-simple-web-application-d4a549e979b9)
* [Versioning](#-version) * [Versioning](#-version)
* [People](#-people) * [People](#-people)

View File

@ -90,6 +90,9 @@ Navigate through examples for a better understanding.
* [method overriding](routing/custom-context/method-overriding/main.go) * [method overriding](routing/custom-context/method-overriding/main.go)
* [new implementation](routing/custom-context/new-implementation/main.go) * [new implementation](routing/custom-context/new-implementation/main.go)
- [Route State](routing/route-state/main.go) - [Route State](routing/route-state/main.go)
- [Writing a middleware](routing/writing-a-middleware)
* [per-route](routing/writing-a-middleware/per-route/main.go)
* [globally](routing/writing-a-middleware/globally/main.go)
### MVC ### MVC

View File

@ -0,0 +1,56 @@
package main
import "github.com/kataras/iris"
func main() {
app := iris.New()
// register the "before" handler as the first handler which will be executed
// on all domain's routes.
// or use the `UseGlobal` to register a middleware which will fire across subdomains.
app.Use(before)
// register the "after" handler as the last handler which will be executed
// after all domain's routes' handler(s).
app.Done(after)
// register our routes.
app.Get("/", indexHandler)
app.Get("/contact", contactHandler)
app.Run(iris.Addr(":8080"))
}
func before(ctx iris.Context) {
shareInformation := "this is a sharable information between handlers"
requestPath := ctx.Path()
println("Before the indexHandler or contactHandler: " + requestPath)
ctx.Values().Set("info", shareInformation)
ctx.Next()
}
func after(ctx iris.Context) {
println("After the indexHandler or contactHandler")
}
func indexHandler(ctx iris.Context) {
println("Inside indexHandler")
// take the info from the "before" handler.
info := ctx.Values().GetString("info")
// write something to the client as a response.
ctx.HTML("<h1>Response</h1>")
ctx.HTML("<br/> Info: " + info)
ctx.Next() // execute the "after" handler registered via `Done`.
}
func contactHandler(ctx iris.Context) {
println("Inside contactHandler")
// write something to the client as a response.
ctx.HTML("<h1>Contact</h1>")
ctx.Next() // execute the "after" handler registered via `Done`.
}

View File

@ -0,0 +1,36 @@
package main
import "github.com/kataras/iris"
func main() {
app := iris.New()
app.Get("/", before, mainHandler, after)
app.Run(iris.Addr(":8080"))
}
func before(ctx iris.Context) {
shareInformation := "this is a sharable information between handlers"
requestPath := ctx.Path()
println("Before the mainHandler: " + requestPath)
ctx.Values().Set("info", shareInformation)
ctx.Next() // execute the next handler, in this case the main one.
}
func after(ctx iris.Context) {
println("After the mainHandler")
}
func mainHandler(ctx iris.Context) {
println("Inside mainHandler")
// take the info from the "before" handler.
info := ctx.Values().GetString("info")
// write something to the client as a response.
ctx.HTML("<h1>Response</h1>")
ctx.HTML("<br/> Info: " + info)
ctx.Next() // execute the "after".
}

View File

@ -251,6 +251,8 @@ func (su *Supervisor) ListenAndServeTLS(certFile string, keyFile string) error {
return err return err
} }
// manually inserted as pre-go 1.9 for any case.
cfg.NextProtos = []string{"h2", "http/1.1"}
su.Server.TLSConfig = cfg su.Server.TLSConfig = cfg
return su.ListenAndServe() return su.ListenAndServe()
} }

10
doc.go
View File

@ -1222,14 +1222,14 @@ Example code:
View Engine View Engine
iris supports 5 template engines out-of-the-box, developers can still use any external golang template engine, Iris supports 5 template engines out-of-the-box, developers can still use any external golang template engine,
as `context/context#ResponseWriter()` is an `io.Writer`. as `context/context#ResponseWriter()` is an `io.Writer`.
All of these five template engines have common features with common API, All of these five template engines have common features with common API,
like Layout, Template Funcs, Party-specific layout, partial rendering and more. like Layout, Template Funcs, Party-specific layout, partial rendering and more.
The standard html, The standard html,
its template parser is the golang.org/pkg/html/template/. its template parser is the golang.org/pkg/html/template/
Django, Django,
its template parser is the github.com/flosch/pongo2 its template parser is the github.com/flosch/pongo2
@ -1251,7 +1251,7 @@ Example code:
import "github.com/kataras/iris" import "github.com/kataras/iris"
func main() { func main() {
app := iris.New() // defaults to these app := iris.New()
// - standard html | iris.HTML(...) // - standard html | iris.HTML(...)
// - django | iris.Django(...) // - django | iris.Django(...)
@ -1268,9 +1268,13 @@ Example code:
// - {{ render_r "header.html" }} // partial relative path to current page // - {{ render_r "header.html" }} // partial relative path to current page
// - {{ yield }} // - {{ yield }}
// - {{ current }} // - {{ current }}
// register a custom template func.
tmpl.AddFunc("greet", func(s string) string { tmpl.AddFunc("greet", func(s string) string {
return "Greetings " + s + "!" return "Greetings " + s + "!"
}) })
// register the view engine to the views, this will load the templates.
app.RegisterView(tmpl) app.RegisterView(tmpl)
app.Get("/", hi) app.Get("/", hi)