AndrewBurian / AndrewBurian/powermux

Change path matching

Abierto
#39 0 comentarios 0 reacciones 0 asignados Ver en GitHub
breaking change enhancement
Lenguaje dominante
Go
Estrellas
20
Forks
4
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.