httprouter

command
v1.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

Example using httprouter middleware

This example shows off using a combination of packages. Using the hnynethttp.WrapHandler around the main httprouter router gets you one basic event for every request that comes through, regardless of what handler it hits. Adding the middleware around each handler gets additional fields that are custom to a matched route.

This example is runnable with go run main.go - it will start listening on port 8080.

Once it's running, in another window, issue a request to the /hello endpoint with a user's name as the variable: curl localhost:8080/hello/ben and you should an event appear on STDOUT in the pane running the example. The event printed will include the pattern matched (/hello/:name) as well as the contents of the name variable.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL