AndrewBurian / AndrewBurian/powermux

Change path matching

Ouverte
#39 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
breaking change enhancement
Langage dominant
Go
Étoiles
20
Forks
4
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Change the way path matching works to be closer to the latest definition from [http.ServeMux](https://golang.org/pkg/net/http/#ServeMux)

- Drop the `*` param in favour of using trailing slashes to indicate rooted trees
- Rework the `Route` syntax to make this apparent

`mux.Handle("/", h)` should handle all paths without a more exact match, as it does in the go mux. Right now this is only achieved via `mux.Handle("/*", h)` and requires another definition for the root itself.

`mux.Handle("thing", h)` and `mux.Handle("thing/", h)` should differentiate between only an exactly match of `thing` and `thing/*` respectively. Without the exact definition, the rooted tree will also match `thing` directly.

Both `thing` AND `thing/` should be able to be defined separately, as the go mux does, and result in different handlers. Being able to do this with the `Route()` syntax is challenging.
A possible implementation:
```go
// registers a and b/ with no specific separate b handler
mux.Route("a").Route("b/")

// registers a, b, and b/
a := mux.Route("a")
a.Route("b")
a.Route("b/")
```

This is more confusing when the rooted tree comes in the middle of a chain
```go
// Will register handlers for a, b/, and c, with no specific handler on b
mux.Route("a").Route("b/").Route("c")

// Requests to /a/b will go to the b/ handler
```

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.