-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ httprule: Add optional "default" handler (#49)
Add an optional "default" handler to `httprule.Handler` that is called if the request does not match any of the gRPC methods. The default is still to return a 404 Not Found status if no "default" handler is supplied. This allows chaining handlers so that other non-gRPC paths can be handled by other handlers, with precedence given to gRPC paths. Refactor `httprule.Server` to `httprule.Handler` and add function options to a new `NewHandler()` constructor. There were already a couple of optional arguments to `NewServer()` and the "default" handler would have been another. So switch to function options, leaving the existing `NewServer()` as is and aliasing `Server` to the new `Handler`. This merges the following commits: * httprule: Rename Server to Handler and implement function options * httprule: Add optional "default" handler main.go | 5 +- serve/httprule/{server.go => handler.go} | 97 +++++++++++++++---- .../{server_test.go => handler_test.go} | 23 ++++- 3 files changed, 105 insertions(+), 20 deletions(-) Co-authored-by: Bob Lail <[email protected]> Pull-request: #49
- Loading branch information
Showing
3 changed files
with
105 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters