Path prefix support for running registry somewhere other than root of server
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
This commit is contained in:
parent
00ce453315
commit
871cf9dd01
7 changed files with 161 additions and 9 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"net/http"
|
||||
"net/http/httptest"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
@ -24,8 +25,16 @@ type routeTestCase struct {
|
|||
//
|
||||
// This may go away as the application structure comes together.
|
||||
func TestRouter(t *testing.T) {
|
||||
baseTestRouter(t, "")
|
||||
}
|
||||
|
||||
router := Router()
|
||||
func TestRouterWithPrefix(t *testing.T) {
|
||||
baseTestRouter(t, "/prefix/")
|
||||
}
|
||||
|
||||
func baseTestRouter(t *testing.T, prefix string) {
|
||||
|
||||
router := RouterWithPrefix(prefix)
|
||||
|
||||
testHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
testCase := routeTestCase{
|
||||
|
@ -147,6 +156,8 @@ func TestRouter(t *testing.T) {
|
|||
StatusCode: http.StatusNotFound,
|
||||
},
|
||||
} {
|
||||
testcase.RequestURI = strings.TrimSuffix(prefix, "/") + testcase.RequestURI
|
||||
|
||||
// Register the endpoint
|
||||
route := router.GetRoute(testcase.RouteName)
|
||||
if route == nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue