Skip to content

Commit 7311000

Browse files
committed
doc: updated, recipe: auto tls
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent 8ab362f commit 7311000

File tree

16 files changed

+88
-37
lines changed

16 files changed

+88
-37
lines changed

echo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Package echo implements a fast and unfancy HTTP server framework for Go (Golang).
2+
Package echo implements high performance, minimalist Go web framework.
33
44
Example:
55

recipe/auto-tls/server.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/labstack/echo"
7+
"github.com/labstack/echo/middleware"
8+
)
9+
10+
func main() {
11+
e := echo.New()
12+
e.Use(middleware.Recover())
13+
e.Use(middleware.Logger())
14+
e.GET("/", func(c echo.Context) error {
15+
return c.HTML(http.StatusOK, `
16+
<h1>Welcome to Echo!</h1>
17+
<h3>TLS certificates automatically installed from Let's Encrypt :)</h3>
18+
`)
19+
})
20+
e.StartAutoTLS(":443", []string{"<your_domain>"}, "le.cache")
21+
}

website/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"baseurl": "https://echo.labstack.com",
33
"languageCode": "en-us",
4-
"title": "Echo - Fast and Unfancy Go Web Framework",
4+
"title": "Echo - High performance, minimalist Go web framework",
55
"canonifyurls": true,
66
"googleAnalytics": "UA-85059636-2",
77
"permalinks": {

website/content/guide/context.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title = "Context"
33
description = "Context in Echo"
44
[menu.main]
55
name = "Context"
6-
identifier = "context"
76
parent = "guide"
87
weight = 5
98
+++

website/content/middleware/basic-auth.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
+++
2-
title = "BasicAuth Middleware"
2+
title = "Basic Auth Middleware"
33
description = "Basic auth middleware for Echo"
44
[menu.main]
5-
name = "BasicAuth"
5+
name = "Basic Auth"
66
parent = "middleware"
77
weight = 5
88
+++
99

10-
BasicAuth middleware provides an HTTP basic authentication.
10+
Basic auth middleware provides an HTTP basic authentication.
1111

1212
- For valid credentials it calls the next handler.
1313
- For invalid credentials, it sends "401 - Unauthorized" response.

website/content/middleware/body-limit.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
+++
2-
title = "BodyLimit Middleware"
2+
title = "Body Limit Middleware"
33
description = "Body limit middleware for Echo"
44
[menu.main]
5-
name = "BodyLimit"
5+
name = "Body Limit"
66
parent = "middleware"
77
weight = 5
88
+++
99

10-
BodyLimit middleware sets the maximum allowed size for a request body, if the
10+
Body limit middleware sets the maximum allowed size for a request body, if the
1111
size exceeds the configured limit, it sends "413 - Request Entity Too Large"
1212
response. The body limit is determined based on both `Content-Length` request
1313
header and actual content read, which makes it super secure.

website/content/middleware/method-override.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
+++
2-
title = "MethodOverride Middleware"
2+
title = "Method Override Middleware"
33
description = "Method override middleware for Echo"
44
[menu.main]
5-
name = "MethodOverride"
5+
name = "Method Override"
66
parent = "middleware"
77
weight = 5
88
+++
99

10-
MethodOverride middleware checks for the overridden method from the request and
10+
Method override middleware checks for the overridden method from the request and
1111
uses it instead of the original method.
1212

1313
For security reasons, only `POST` method can be overridden.

website/content/middleware/redirect.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ description = "Redirect middleware for Echo"
77
weight = 5
88
+++
99

10-
## HTTPSRedirect
10+
## HTTPS Redirect
1111

12-
HTTPSRedirect middleware redirects http requests to https.
12+
HTTPS redirect middleware redirects http requests to https.
1313
For example, http://labstack.com will be redirected to https://labstack.com.
1414

1515
*Usage*
@@ -19,9 +19,9 @@ e := echo.New()
1919
e.Pre(middleware.HTTPSRedirect())
2020
```
2121

22-
## HTTPSWWWRedirect
22+
## HTTPS WWW Redirect
2323

24-
HTTPSWWWRedirect redirects http requests to www https.
24+
HTTPS WWW redirect redirects http requests to www https.
2525
For example, http://labstack.com will be redirected to https://www.labstack.com.
2626

2727
*Usage*
@@ -31,9 +31,9 @@ e := echo.New()
3131
e.Pre(middleware.HTTPSWWWRedirect())
3232
```
3333

34-
## HTTPSNonWWWRedirect
34+
## HTTPS NonWWW Redirect
3535

36-
HTTPSNonWWWRedirect redirects http requests to https non www.
36+
HTTPS NonWWW redirect redirects http requests to https non www.
3737
For example, http://www.labstack.com will be redirect to https://labstack.com.
3838

3939
*Usage*
@@ -43,9 +43,9 @@ e := echo.New()
4343
e.Pre(middleware.HTTPSNonWWWRedirect())
4444
```
4545

46-
## WWWRedirect
46+
## WWW Redirect
4747

48-
WWWRedirect redirects non www requests to www.
48+
WWW redirect redirects non www requests to www.
4949

5050
For example, http://labstack.com will be redirected to http://www.labstack.com.
5151

@@ -56,9 +56,9 @@ e := echo.New()
5656
e.Pre(middleware.WWWRedirect())
5757
```
5858

59-
## NonWWWRedirect
59+
## NonWWW Redirect
6060

61-
NonWWWRedirect redirects www requests to non www.
61+
NonWWW redirect redirects www requests to non www.
6262
For example, http://www.labstack.com will be redirected to http://labstack.com.
6363

6464
*Usage*

website/content/middleware/trailing-slash.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
+++
2-
title = "TrailingSlash Middleware"
2+
title = "Trailing Slash Middleware"
33
description = "Trailing slash middleware for Echo"
44
[menu.main]
5-
name = "TrailingSlash"
5+
name = "Trailing Slash"
66
parent = "middleware"
77
weight = 5
88
+++
99

10-
## AddTrailingSlash Middleware
10+
## Add Trailing Slash
1111

12-
AddTrailingSlash middleware adds a trailing slash to the request URI.
12+
Add trailing slash middleware adds a trailing slash to the request URI.
1313

1414
*Usage*
1515

@@ -18,9 +18,9 @@ e := echo.New()
1818
e.Pre(middleware.AddTrailingSlash())
1919
```
2020

21-
## RemoveTrailingSlash Middleware
21+
## Remove Trailing Slash
2222

23-
RemoveTrailingSlash middleware removes a trailing slash from the request URI.
23+
Remove trailing slash middleware removes a trailing slash from the request URI.
2424

2525
*Usage*
2626

website/content/recipes/auto-tls.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
+++
2+
title = "Auto TLS Example"
3+
description = "Automatic TLS certificates from Let's Encrypt example for Echo"
4+
[menu.main]
5+
name = "Auto TLS"
6+
parent = "recipes"
7+
weight = 2
8+
+++
9+
10+
This recipe shows how to obtain TLS certificates for a domain automatically from
11+
Let's Encrypt. `Echo#StartAutoTLS` accepts address which should listen on port `443`,
12+
list of host names for security and a file path to cache the certificates.
13+
14+
Browse to https://<your_domain>. If everything goes fine, you should see a welcome
15+
message with TLS enabled on the website.
16+
17+
> To redirect HTTP traffic to HTTPS, you can use [redirect middleware](/middleware/redirect#https-redirect)
18+
19+
## Server
20+
21+
`server.go`
22+
23+
{{< embed "auto-tls/server.go" >}}
24+
25+
## [Source Code]({{< source "auto-tls" >}})
26+
27+
## Maintainers
28+
29+
- [vishr](https://github.com/vishr)

website/content/recipes/cors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title = "CORS Example"
33
description = "CORS example for Echo"
44
[menu.main]
55
name = "CORS"
6-
identifier = "cors-middleware"
6+
identifier = "middleware-cors"
77
parent = "recipes"
88
weight = 3
99
+++

website/content/recipes/http2.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ description = "HTTP/2 example for Echo"
77
weight = 3
88
+++
99

10-
## What is HTTP/2?
11-
1210
HTTP/2 (originally named HTTP/2.0) is the second major version of the HTTP network
13-
protocol used by the World Wide Web
11+
protocol used by the World Wide Web. HTTP/2 improves speed and provides better user
12+
experience.
1413

15-
### Features
14+
### Key Features
1615

1716
- Binary, instead of textual.
1817
- Fully multiplexed, instead of ordered and blocking, can therefore use just one TCP connection.

website/content/recipes/jwt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title = "JWT Example"
33
description = "JWT example for Echo"
44
[menu.main]
55
name = "JWT"
6-
identifier = "jwt-recipe"
6+
identifier = "recipe-jwt"
77
parent = "recipes"
88
weight = 11
99
+++

website/data/index.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ description = "High performance, extensible, minimalist Go web framework"
1515
icon = "license"
1616
title = "Automatic TLS"
1717
text = "Automatically install TLS certificates from Let's Encrypt."
18+
[[features]]
19+
icon = "speed_fast"
20+
title = "HTTP/2"
21+
text = "HTTP/2 support improves speed and provides better user experience."
1822
[[features]]
1923
icon = "funnel"
2024
title = "Middleware"

website/layouts/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<div class="w3-row-padding">
1010
<div class="w3-col m10 l10">
1111
<div class="hero">
12-
<h1 class="heading">{{ .Site.Data.index.heading }}</h1>
13-
<h2 class="description">{{ .Site.Data.index.description }}</h2>
12+
<h1>{{ .Site.Data.index.heading }}</h1>
13+
<h2>{{ .Site.Data.index.description }}</h2>
1414
<p>
1515
<img style="width: 100%;" src="/images/echo_terminal.png" alt="Echo">
1616
</p>

website/static/styles/main.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

0 commit comments

Comments
 (0)