forked from redpanda-data/connect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http_server i/o no longer treat all paths as prefixes
- Loading branch information
Showing
9 changed files
with
89 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,21 @@ | ||
// Package api implements a type used for creating the Benthos HTTP API. | ||
package api | ||
|
||
import ( | ||
"github.com/gorilla/mux" | ||
) | ||
|
||
// GetMuxRoute returns a *mux.Route (the result of calling .Path or .PathPrefix | ||
// on the provided router), where in cases where the path ends in a slash it | ||
// will be treated as a prefix. This isn't ideal but it's as close as we can | ||
// realistically get to the http.ServeMux behaviour with added path variables. | ||
// | ||
// NOTE: Eventually we can move back to http.ServeMux once | ||
// https://github.com/golang/go/issues/61410 is available, and that'll allow us | ||
// to make all paths explicit. | ||
func GetMuxRoute(gMux *mux.Router, path string) *mux.Route { | ||
if len(path) > 0 && path[len(path)-1] == '/' { | ||
return gMux.PathPrefix(path) | ||
} | ||
return gMux.Path(path) | ||
} |
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
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