Browse Source

renamed

pull/598/head
Bergutov Ruslan 5 years ago
parent
commit
95b356a939
  1. 4
      README.md
  2. 2
      example_router_test.go

4
README.md

@ -28,7 +28,7 @@ The name mux stands for "HTTP request multiplexer". Like the standard `http.Serv
* [Serving Single Page Applications](#serving-single-page-applications) (e.g. React, Vue, Ember.js, etc.) * [Serving Single Page Applications](#serving-single-page-applications) (e.g. React, Vue, Ember.js, etc.)
* [Registered URLs](#registered-urls) * [Registered URLs](#registered-urls)
* [Walking Routes](#walking-routes) * [Walking Routes](#walking-routes)
* [Alias Pattern Registration](#pattern-registration) * [Re-using Regular Expressions](#re-using-regular-expressions)
* [Graceful Shutdown](#graceful-shutdown) * [Graceful Shutdown](#graceful-shutdown)
* [Middleware](#middleware) * [Middleware](#middleware)
* [Handling CORS Requests](#handling-cors-requests) * [Handling CORS Requests](#handling-cors-requests)
@ -436,7 +436,7 @@ func main() {
} }
``` ```
### Alias Pattern Registration ### Re-using Regular Expressions
There can be a situation when you often need to specify some complex regular expressions inside your paths, e.g. uuid. This can be easily shorthanded: There can be a situation when you often need to specify some complex regular expressions inside your paths, e.g. uuid. This can be easily shorthanded:

2
example_router_test.go

@ -7,7 +7,7 @@ import (
) )
// This example demonstrates alias pattern registration on router // This example demonstrates alias pattern registration on router
func ExampleRouter_RegisterPattern() { func ExampleRegisterPattern() {
r := mux.NewRouter().RegisterPattern("uuid", "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}") r := mux.NewRouter().RegisterPattern("uuid", "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[8|9|aA|bB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}")
route := r.Path("/category/{id:uuid}") route := r.Path("/category/{id:uuid}")

Loading…
Cancel
Save