1
0
mirror of https://github.com/labstack/echo.git synced 2025-02-15 13:53:06 +02:00

doc: updated, recipe: auto tls

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-11-28 20:30:42 -08:00
parent 8ab362f61d
commit 73110004ef
16 changed files with 88 additions and 37 deletions

View File

@ -1,5 +1,5 @@
/*
Package echo implements a fast and unfancy HTTP server framework for Go (Golang).
Package echo implements high performance, minimalist Go web framework.
Example:

21
recipe/auto-tls/server.go Normal file
View File

@ -0,0 +1,21 @@
package main
import (
"net/http"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
)
func main() {
e := echo.New()
e.Use(middleware.Recover())
e.Use(middleware.Logger())
e.GET("/", func(c echo.Context) error {
return c.HTML(http.StatusOK, `
<h1>Welcome to Echo!</h1>
<h3>TLS certificates automatically installed from Let's Encrypt :)</h3>
`)
})
e.StartAutoTLS(":443", []string{"<your_domain>"}, "le.cache")
}

View File

@ -1,7 +1,7 @@
{
"baseurl": "https://echo.labstack.com",
"languageCode": "en-us",
"title": "Echo - Fast and Unfancy Go Web Framework",
"title": "Echo - High performance, minimalist Go web framework",
"canonifyurls": true,
"googleAnalytics": "UA-85059636-2",
"permalinks": {

View File

@ -3,7 +3,6 @@ title = "Context"
description = "Context in Echo"
[menu.main]
name = "Context"
identifier = "context"
parent = "guide"
weight = 5
+++

View File

@ -1,13 +1,13 @@
+++
title = "BasicAuth Middleware"
title = "Basic Auth Middleware"
description = "Basic auth middleware for Echo"
[menu.main]
name = "BasicAuth"
name = "Basic Auth"
parent = "middleware"
weight = 5
+++
BasicAuth middleware provides an HTTP basic authentication.
Basic auth middleware provides an HTTP basic authentication.
- For valid credentials it calls the next handler.
- For invalid credentials, it sends "401 - Unauthorized" response.

View File

@ -1,13 +1,13 @@
+++
title = "BodyLimit Middleware"
title = "Body Limit Middleware"
description = "Body limit middleware for Echo"
[menu.main]
name = "BodyLimit"
name = "Body Limit"
parent = "middleware"
weight = 5
+++
BodyLimit middleware sets the maximum allowed size for a request body, if the
Body limit middleware sets the maximum allowed size for a request body, if the
size exceeds the configured limit, it sends "413 - Request Entity Too Large"
response. The body limit is determined based on both `Content-Length` request
header and actual content read, which makes it super secure.

View File

@ -1,13 +1,13 @@
+++
title = "MethodOverride Middleware"
title = "Method Override Middleware"
description = "Method override middleware for Echo"
[menu.main]
name = "MethodOverride"
name = "Method Override"
parent = "middleware"
weight = 5
+++
MethodOverride middleware checks for the overridden method from the request and
Method override middleware checks for the overridden method from the request and
uses it instead of the original method.
For security reasons, only `POST` method can be overridden.

View File

@ -7,9 +7,9 @@ description = "Redirect middleware for Echo"
weight = 5
+++
## HTTPSRedirect
## HTTPS Redirect
HTTPSRedirect middleware redirects http requests to https.
HTTPS redirect middleware redirects http requests to https.
For example, http://labstack.com will be redirected to https://labstack.com.
*Usage*
@ -19,9 +19,9 @@ e := echo.New()
e.Pre(middleware.HTTPSRedirect())
```
## HTTPSWWWRedirect
## HTTPS WWW Redirect
HTTPSWWWRedirect redirects http requests to www https.
HTTPS WWW redirect redirects http requests to www https.
For example, http://labstack.com will be redirected to https://www.labstack.com.
*Usage*
@ -31,9 +31,9 @@ e := echo.New()
e.Pre(middleware.HTTPSWWWRedirect())
```
## HTTPSNonWWWRedirect
## HTTPS NonWWW Redirect
HTTPSNonWWWRedirect redirects http requests to https non www.
HTTPS NonWWW redirect redirects http requests to https non www.
For example, http://www.labstack.com will be redirect to https://labstack.com.
*Usage*
@ -43,9 +43,9 @@ e := echo.New()
e.Pre(middleware.HTTPSNonWWWRedirect())
```
## WWWRedirect
## WWW Redirect
WWWRedirect redirects non www requests to www.
WWW redirect redirects non www requests to www.
For example, http://labstack.com will be redirected to http://www.labstack.com.
@ -56,9 +56,9 @@ e := echo.New()
e.Pre(middleware.WWWRedirect())
```
## NonWWWRedirect
## NonWWW Redirect
NonWWWRedirect redirects www requests to non www.
NonWWW redirect redirects www requests to non www.
For example, http://www.labstack.com will be redirected to http://labstack.com.
*Usage*

View File

@ -1,15 +1,15 @@
+++
title = "TrailingSlash Middleware"
title = "Trailing Slash Middleware"
description = "Trailing slash middleware for Echo"
[menu.main]
name = "TrailingSlash"
name = "Trailing Slash"
parent = "middleware"
weight = 5
+++
## AddTrailingSlash Middleware
## Add Trailing Slash
AddTrailingSlash middleware adds a trailing slash to the request URI.
Add trailing slash middleware adds a trailing slash to the request URI.
*Usage*
@ -18,9 +18,9 @@ e := echo.New()
e.Pre(middleware.AddTrailingSlash())
```
## RemoveTrailingSlash Middleware
## Remove Trailing Slash
RemoveTrailingSlash middleware removes a trailing slash from the request URI.
Remove trailing slash middleware removes a trailing slash from the request URI.
*Usage*

View File

@ -0,0 +1,29 @@
+++
title = "Auto TLS Example"
description = "Automatic TLS certificates from Let's Encrypt example for Echo"
[menu.main]
name = "Auto TLS"
parent = "recipes"
weight = 2
+++
This recipe shows how to obtain TLS certificates for a domain automatically from
Let's Encrypt. `Echo#StartAutoTLS` accepts address which should listen on port `443`,
list of host names for security and a file path to cache the certificates.
Browse to https://<your_domain>. If everything goes fine, you should see a welcome
message with TLS enabled on the website.
> To redirect HTTP traffic to HTTPS, you can use [redirect middleware](/middleware/redirect#https-redirect)
## Server
`server.go`
{{< embed "auto-tls/server.go" >}}
## [Source Code]({{< source "auto-tls" >}})
## Maintainers
- [vishr](https://github.com/vishr)

View File

@ -3,7 +3,7 @@ title = "CORS Example"
description = "CORS example for Echo"
[menu.main]
name = "CORS"
identifier = "cors-middleware"
identifier = "middleware-cors"
parent = "recipes"
weight = 3
+++

View File

@ -7,12 +7,11 @@ description = "HTTP/2 example for Echo"
weight = 3
+++
## What is HTTP/2?
HTTP/2 (originally named HTTP/2.0) is the second major version of the HTTP network
protocol used by the World Wide Web
protocol used by the World Wide Web. HTTP/2 improves speed and provides better user
experience.
### Features
### Key Features
- Binary, instead of textual.
- Fully multiplexed, instead of ordered and blocking, can therefore use just one TCP connection.

View File

@ -3,7 +3,7 @@ title = "JWT Example"
description = "JWT example for Echo"
[menu.main]
name = "JWT"
identifier = "jwt-recipe"
identifier = "recipe-jwt"
parent = "recipes"
weight = 11
+++

View File

@ -15,6 +15,10 @@ description = "High performance, extensible, minimalist Go web framework"
icon = "license"
title = "Automatic TLS"
text = "Automatically install TLS certificates from Let's Encrypt."
[[features]]
icon = "speed_fast"
title = "HTTP/2"
text = "HTTP/2 support improves speed and provides better user experience."
[[features]]
icon = "funnel"
title = "Middleware"

View File

@ -9,8 +9,8 @@
<div class="w3-row-padding">
<div class="w3-col m10 l10">
<div class="hero">
<h1 class="heading">{{ .Site.Data.index.heading }}</h1>
<h2 class="description">{{ .Site.Data.index.description }}</h2>
<h1>{{ .Site.Data.index.heading }}</h1>
<h2>{{ .Site.Data.index.description }}</h2>
<p>
<img style="width: 100%;" src="/images/echo_terminal.png" alt="Echo">
</p>

View File

@ -1 +0,0 @@