Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for routing Host introduced in 0.18.2 #605

Merged
merged 3 commits into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions templates/en/docs/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ Buffalo uses the [github.com/gorilla/mux](http://www.gorillatoolkit.org/pkg/mux)
<%= partial("en/docs/routing/params.md") %>
<%= partial("en/docs/routing/named_params.md") %>
<%= partial("en/docs/routing/groups.md") %>
<%= partial("en/docs/routing/hosts.md") %>
<%= partial("en/docs/routing/mounting.md") %>
33 changes: 33 additions & 0 deletions templates/en/docs/routing/_hosts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Hosts

<%= sinceVersion("0.18.2") %>

Buffalo apps also support grouping of end-points by host. Host creates a new group that matches the domain passed. This is useful for creating groups of end-points for different domains or subdomains.
stanislas-m marked this conversation as resolved.
Show resolved Hide resolved

```go
app := buffalo.New(buffalo.Options{
Env: envy.Get("GO_ENV", "development"),
SessionName: "_coke_session",
})

subApp := app.Host("docs.domain.com")
subApp.GET("/", func (c buffalo.Context) error {
return c.Render(http.StatusOK, r.String("docs.domain.com Homepage"))
})

domainApp := app.Host("example.com")
domainApp.GET("/", func (c buffalo.Context) error {
return c.Render(http.StatusOK, r.String("example.com Homepage"))
})

app.GET("/", func (c buffalo.Context) error {
return c.Render(http.StatusOK, r.String("Main App Homepage"))
})
```

Variables mapped to parameters are also supported:

```go
app.Host("{subdomain}.example.com")
app.Host("{subdomain:[a-z]+}.example.com")
```
1 change: 1 addition & 0 deletions templates/fr/docs/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ Buffalo utilise le paquet [github.com/gorilla/mux](http://www.gorillatoolkit.org
<%= partial("fr/docs/routing/params.md") %>
<%= partial("fr/docs/routing/named_params.md") %>
<%= partial("fr/docs/routing/groups.md") %>
<%= partial("fr/docs/routing/hosts.md") %>
<%= partial("fr/docs/routing/mounting.md") %>
33 changes: 33 additions & 0 deletions templates/fr/docs/routing/_hosts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Hôtes

<%= sinceVersion("0.18.2") %>

Buffalo prennent également en charge le regroupement des points de terminaison par hôte. L'hôte crée un nouveau groupe qui correspond au domaine transmis. Ceci est utile pour créer des groupes de points de terminaison pour différents domaines ou sous-domaines.
stanislas-m marked this conversation as resolved.
Show resolved Hide resolved

```go
app := buffalo.New(buffalo.Options{
Env: envy.Get("GO_ENV", "development"),
SessionName: "_coke_session",
})

subApp := app.Host("docs.domain.com")
subApp.GET("/", func (c buffalo.Context) error {
return c.Render(http.StatusOK, r.String("docs.domain.com Homepage"))
})

domainApp := app.Host("example.com")
domainApp.GET("/", func (c buffalo.Context) error {
return c.Render(http.StatusOK, r.String("example.com Homepage"))
})

app.GET("/", func (c buffalo.Context) error {
return c.Render(http.StatusOK, r.String("Main App Homepage"))
})
```

Les variables mappées aux paramètres sont également prises en charge:
stanislas-m marked this conversation as resolved.
Show resolved Hide resolved

```go
app.Host("{subdomain}.example.com")
app.Host("{subdomain:[a-z]+}.example.com")
```