Skip to content

Commit

Permalink
doc: updated, recipe: auto tls
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
vishr committed Nov 29, 2016
1 parent 8ab362f commit 7311000
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 37 deletions.
2 changes: 1 addition & 1 deletion echo.go
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
21 changes: 21 additions & 0 deletions recipe/auto-tls/server.go
Original file line number Diff line number Diff line change
@@ -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")
}
2 changes: 1 addition & 1 deletion website/config.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
1 change: 0 additions & 1 deletion website/content/guide/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ title = "Context"
description = "Context in Echo"
[menu.main]
name = "Context"
identifier = "context"
parent = "guide"
weight = 5
+++
Expand Down
6 changes: 3 additions & 3 deletions website/content/middleware/basic-auth.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 3 additions & 3 deletions website/content/middleware/body-limit.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 3 additions & 3 deletions website/content/middleware/method-override.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
20 changes: 10 additions & 10 deletions website/content/middleware/redirect.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand All @@ -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*
Expand All @@ -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*
Expand All @@ -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.

Expand All @@ -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*
Expand Down
12 changes: 6 additions & 6 deletions website/content/middleware/trailing-slash.md
Original file line number Diff line number Diff line change
@@ -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*

Expand All @@ -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*

Expand Down
29 changes: 29 additions & 0 deletions website/content/recipes/auto-tls.md
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion website/content/recipes/cors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
+++
Expand Down
7 changes: 3 additions & 4 deletions website/content/recipes/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion website/content/recipes/jwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
+++
Expand Down
4 changes: 4 additions & 0 deletions website/data/index.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions website/layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 0 additions & 1 deletion website/static/styles/main.css
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

0 comments on commit 7311000

Please sign in to comment.