Skip to content

Commit ff8371b

Browse files
authored
Merge pull request #115 from jnichols-git/beta.4
make route/router public, fix user guide
2 parents 852aacb + 9b8ce3e commit ff8371b

File tree

16 files changed

+43
-43
lines changed

16 files changed

+43
-43
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FORCE:
22

3-
test:
3+
test: FORCE
44
go test -coverprofile cicd/cover.out ./...
55

66
cover: test

docs/user-guide.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# Matcha User Guide
22

3-
- [Matcha User Guide](#matcha-user-guide)
4-
- [Basics](#basics)
5-
- [Hello World](#hello-world)
6-
- [Echo Server with Route Parameters](#echo-server-with-route-parameters)
7-
- [File Server with Partial Routes](#file-server-with-partial-routes)
8-
- [Advanced Usage](#advanced-usage)
9-
- [Mounting Subrouters](#mounting-subrouters)
10-
- [Middleware](#middleware)
11-
- [Requirements](#requirements)
12-
- [FAQ](#faq)
13-
- [Why are some of my routes not matched when they should be?](#why-are-some-of-my-routes-not-matched-when-they-should-be)
3+
- [Basics](#basics)
4+
- [Hello World](#hello-world)
5+
- [Echo Server with Route Parameters](#echo-server-with-route-parameters)
6+
- [File Server with Partial Routes](#file-server-with-partial-routes)
7+
- [Advanced Usage](#advanced-usage)
8+
- [Mounting Subrouters](#mounting-subrouters)
9+
- [Middleware](#middleware)
10+
- [Requirements](#requirements)
11+
- [FAQ](#faq)
12+
- [Why are some of my routes not matched when they should be?](#why-are-some-of-my-routes-not-matched-when-they-should-be)
1413

1514
Hello! This is a step-by-step guide to using Matcha for HTTP handling in Go.
1615

@@ -20,7 +19,9 @@ There are a few examples in the `examples` directory to show basic usage.
2019

2120
### Hello World
2221

23-
You can use `matcha.Router` to create a new Router and `router.HandleFunc` to handle a request path.
22+
You can use `matcha.Router` to create a new Router and `router.HandleFunc` to
23+
handle a request path. Routers are type `*router.Router` if you need to store
24+
it.
2425

2526
```go
2627
package main
@@ -190,14 +191,12 @@ $
190191
Requirements are defined in `require` as a `func(*http.Request) bool`. If you need more tools to check routes, you can `Require` a requirement with any Route. If this function returns false for any request, the route is not matched, but it can still match any routes after.
191192

192193
```go
193-
webRoute, err := route.New(
194+
webRoute, err := matcha.Route(
194195
http.MethodGet, "/",
195-
route.Require(require.HostPorts("https://[www.|]jnichols.info")),
196-
)
197-
apiRoute, err := route.New(
196+
).Require(require.HostPorts("https://[www.|]jnichols.info"))
197+
apiRoute, err := matcha.Route(
198198
http.MethodGet, "/",
199-
require.HostPorts("https://api.jnichols.info"),
200-
)
199+
).Require(require.HostPorts("https://api.jnichols.info"))
201200
```
202201

203202
## FAQ

internal/tree/tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"sync/atomic"
99

1010
"github.com/jnichols-git/matcha/v2/internal/path"
11-
"github.com/jnichols-git/matcha/v2/internal/route"
1211
"github.com/jnichols-git/matcha/v2/require"
12+
"github.com/jnichols-git/matcha/v2/route"
1313
)
1414

1515
const NO_LEAF_ID = int64(0)

internal/tree/tree_bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"net/http"
66
"testing"
77

8-
"github.com/jnichols-git/matcha/v2/internal/route"
8+
"github.com/jnichols-git/matcha/v2/route"
99
)
1010

1111
var routes []string = []string{

internal/tree/tree_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66
"testing"
77

88
"github.com/jnichols-git/matcha/v2/internal/rctx"
9-
"github.com/jnichols-git/matcha/v2/internal/route"
109
"github.com/jnichols-git/matcha/v2/require"
10+
"github.com/jnichols-git/matcha/v2/route"
1111
)
1212

1313
func TestTree(t *testing.T) {

matcha.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"net/http"
55

66
"github.com/jnichols-git/matcha/v2/internal/rctx"
7-
"github.com/jnichols-git/matcha/v2/internal/route"
8-
"github.com/jnichols-git/matcha/v2/internal/router"
7+
"github.com/jnichols-git/matcha/v2/route"
8+
"github.com/jnichols-git/matcha/v2/router"
99
)
1010

1111
func Route(method, expr string) (r *route.Route, err error) {
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)