nghttpx: Rename backend/replace API as backendconfig
This commit is contained in:
parent
11bca9a98a
commit
81bfb84b32
|
@ -493,14 +493,14 @@ some cases where the error has occurred before reaching API endpoint
|
||||||
|
|
||||||
The following section describes available API endpoints.
|
The following section describes available API endpoints.
|
||||||
|
|
||||||
PUT /api/v1beta1/backend/replace
|
PUT /api/v1beta1/backendconfig
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
This API replaces the current set of backend servers with the
|
This API replaces the current backend server settings with the
|
||||||
requested ones. The request must carry request body with method PUT
|
requested ones. The request method should be PUT, but POST is also
|
||||||
or POST. The request body must be nghttpx configuration file format.
|
acceptable. The request body must be nghttpx configuration file
|
||||||
For configuration file format, see `FILES`_ section. The line
|
format. For configuration file format, see `FILES`_ section. The
|
||||||
separator inside the request body must be single LF (0x0A).
|
line separator inside the request body must be single LF (0x0A).
|
||||||
Currently, only :option:`backend <--backend>` option is parsed, the
|
Currently, only :option:`backend <--backend>` option is parsed, the
|
||||||
others are simply ignored. The semantics of this API is replace the
|
others are simply ignored. The semantics of this API is replace the
|
||||||
current backend with the backend options in request body. Describe
|
current backend with the backend options in request body. Describe
|
||||||
|
|
|
@ -795,7 +795,7 @@ func TestH1H2RespPhaseReturn(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestH1APIBackendReplace exercise backend/replace API endpoint
|
// TestH1APIBackendReplace exercise backendconfig API endpoint
|
||||||
// routine for successful case.
|
// routine for successful case.
|
||||||
func TestH1APIBackendReplace(t *testing.T) {
|
func TestH1APIBackendReplace(t *testing.T) {
|
||||||
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -805,7 +805,7 @@ func TestH1APIBackendReplace(t *testing.T) {
|
||||||
|
|
||||||
res, err := st.http1(requestParam{
|
res, err := st.http1(requestParam{
|
||||||
name: "TestH1APIBackendReplace",
|
name: "TestH1APIBackendReplace",
|
||||||
path: "/api/v1beta1/backend/replace",
|
path: "/api/v1beta1/backendconfig",
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: []byte(`# comment
|
body: []byte(`# comment
|
||||||
backend=127.0.0.1,3011
|
backend=127.0.0.1,3011
|
||||||
|
@ -832,7 +832,7 @@ backend=127.0.0.1,3011
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestH1APIBackendReplaceBadMethod exercise backend/replace API
|
// TestH1APIBackendReplaceBadMethod exercise backendconfig API
|
||||||
// endpoint routine with bad method.
|
// endpoint routine with bad method.
|
||||||
func TestH1APIBackendReplaceBadMethod(t *testing.T) {
|
func TestH1APIBackendReplaceBadMethod(t *testing.T) {
|
||||||
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -842,7 +842,7 @@ func TestH1APIBackendReplaceBadMethod(t *testing.T) {
|
||||||
|
|
||||||
res, err := st.http1(requestParam{
|
res, err := st.http1(requestParam{
|
||||||
name: "TestH1APIBackendReplaceBadMethod",
|
name: "TestH1APIBackendReplaceBadMethod",
|
||||||
path: "/api/v1beta1/backend/replace",
|
path: "/api/v1beta1/backendconfig",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
body: []byte(`# comment
|
body: []byte(`# comment
|
||||||
backend=127.0.0.1,3011
|
backend=127.0.0.1,3011
|
||||||
|
@ -869,8 +869,8 @@ backend=127.0.0.1,3011
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestH1APINotFound exercise backend/replace API endpoint routine
|
// TestH1APINotFound exercise backendconfig API endpoint routine when
|
||||||
// when API endpoint is not found.
|
// API endpoint is not found.
|
||||||
func TestH1APINotFound(t *testing.T) {
|
func TestH1APINotFound(t *testing.T) {
|
||||||
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
t.Fatalf("request should not be forwarded")
|
t.Fatalf("request should not be forwarded")
|
||||||
|
|
|
@ -1845,7 +1845,7 @@ func TestH2H2RespPhaseReturn(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestH2APIBackendReplace exercise backend/replace API endpoint
|
// TestH2APIBackendReplace exercise backendconfig API endpoint
|
||||||
// routine for successful case.
|
// routine for successful case.
|
||||||
func TestH2APIBackendReplace(t *testing.T) {
|
func TestH2APIBackendReplace(t *testing.T) {
|
||||||
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -1855,7 +1855,7 @@ func TestH2APIBackendReplace(t *testing.T) {
|
||||||
|
|
||||||
res, err := st.http2(requestParam{
|
res, err := st.http2(requestParam{
|
||||||
name: "TestH2APIBackendReplace",
|
name: "TestH2APIBackendReplace",
|
||||||
path: "/api/v1beta1/backend/replace",
|
path: "/api/v1beta1/backendconfig",
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: []byte(`# comment
|
body: []byte(`# comment
|
||||||
backend=127.0.0.1,3011
|
backend=127.0.0.1,3011
|
||||||
|
@ -1882,7 +1882,7 @@ backend=127.0.0.1,3011
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestH2APIBackendReplaceBadMethod exercise backend/replace API
|
// TestH2APIBackendReplaceBadMethod exercise backendconfig API
|
||||||
// endpoint routine with bad method.
|
// endpoint routine with bad method.
|
||||||
func TestH2APIBackendReplaceBadMethod(t *testing.T) {
|
func TestH2APIBackendReplaceBadMethod(t *testing.T) {
|
||||||
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -1892,7 +1892,7 @@ func TestH2APIBackendReplaceBadMethod(t *testing.T) {
|
||||||
|
|
||||||
res, err := st.http2(requestParam{
|
res, err := st.http2(requestParam{
|
||||||
name: "TestH2APIBackendReplaceBadMethod",
|
name: "TestH2APIBackendReplaceBadMethod",
|
||||||
path: "/api/v1beta1/backend/replace",
|
path: "/api/v1beta1/backendconfig",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
body: []byte(`# comment
|
body: []byte(`# comment
|
||||||
backend=127.0.0.1,3011
|
backend=127.0.0.1,3011
|
||||||
|
@ -1919,8 +1919,8 @@ backend=127.0.0.1,3011
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestH2APINotFound exercise backend/replace API endpoint routine
|
// TestH2APINotFound exercise backendconfig API endpoint routine when
|
||||||
// when API endpoint is not found.
|
// API endpoint is not found.
|
||||||
func TestH2APINotFound(t *testing.T) {
|
func TestH2APINotFound(t *testing.T) {
|
||||||
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
st := newServerTesterConnectPort([]string{"-f127.0.0.1,3010;api;no-tls"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
t.Fatalf("request should not be forwarded")
|
t.Fatalf("request should not be forwarded")
|
||||||
|
|
|
@ -476,7 +476,7 @@ func TestS3H2RespPhaseReturn(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestS3APIBackendReplace exercise backend/replace API endpoint
|
// TestS3APIBackendReplace exercise backendconfig API endpoint
|
||||||
// routine for successful case.
|
// routine for successful case.
|
||||||
func TestS3APIBackendReplace(t *testing.T) {
|
func TestS3APIBackendReplace(t *testing.T) {
|
||||||
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3010;api"}, t, func(w http.ResponseWriter, r *http.Request) {
|
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3010;api"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -486,7 +486,7 @@ func TestS3APIBackendReplace(t *testing.T) {
|
||||||
|
|
||||||
res, err := st.spdy(requestParam{
|
res, err := st.spdy(requestParam{
|
||||||
name: "TestS3APIBackendReplace",
|
name: "TestS3APIBackendReplace",
|
||||||
path: "/api/v1beta1/backend/replace",
|
path: "/api/v1beta1/backendconfig",
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: []byte(`# comment
|
body: []byte(`# comment
|
||||||
backend=127.0.0.1,3011
|
backend=127.0.0.1,3011
|
||||||
|
@ -513,7 +513,7 @@ backend=127.0.0.1,3011
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestS3APIBackendReplaceBadMethod exercise backend/replace API
|
// TestS3APIBackendReplaceBadMethod exercise backendconfig API
|
||||||
// endpoint routine with bad method.
|
// endpoint routine with bad method.
|
||||||
func TestS3APIBackendReplaceBadMethod(t *testing.T) {
|
func TestS3APIBackendReplaceBadMethod(t *testing.T) {
|
||||||
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3010;api"}, t, func(w http.ResponseWriter, r *http.Request) {
|
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3010;api"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -523,7 +523,7 @@ func TestS3APIBackendReplaceBadMethod(t *testing.T) {
|
||||||
|
|
||||||
res, err := st.spdy(requestParam{
|
res, err := st.spdy(requestParam{
|
||||||
name: "TestS3APIBackendReplaceBadMethod",
|
name: "TestS3APIBackendReplaceBadMethod",
|
||||||
path: "/api/v1beta1/backend/replace",
|
path: "/api/v1beta1/backendconfig",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
body: []byte(`# comment
|
body: []byte(`# comment
|
||||||
backend=127.0.0.1,3011
|
backend=127.0.0.1,3011
|
||||||
|
@ -550,8 +550,8 @@ backend=127.0.0.1,3011
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestS3APINotFound exercise backend/replace API endpoint routine
|
// TestS3APINotFound exercise backendconfig API endpoint routine when
|
||||||
// when API endpoint is not found.
|
// API endpoint is not found.
|
||||||
func TestS3APINotFound(t *testing.T) {
|
func TestS3APINotFound(t *testing.T) {
|
||||||
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3010;api"}, t, func(w http.ResponseWriter, r *http.Request) {
|
st := newServerTesterTLSConnectPort([]string{"--npn-list=spdy/3.1", "-f127.0.0.1,3010;api"}, t, func(w http.ResponseWriter, r *http.Request) {
|
||||||
t.Fatalf("request should not be forwarded")
|
t.Fatalf("request should not be forwarded")
|
||||||
|
|
|
@ -131,7 +131,7 @@ int APIDownstreamConnection::push_request_headers() {
|
||||||
auto &req = downstream_->request();
|
auto &req = downstream_->request();
|
||||||
auto &resp = downstream_->response();
|
auto &resp = downstream_->response();
|
||||||
|
|
||||||
if (req.path != StringRef::from_lit("/api/v1beta1/backend/replace")) {
|
if (req.path != StringRef::from_lit("/api/v1beta1/backendconfig")) {
|
||||||
send_reply(404, API_FAILURE);
|
send_reply(404, API_FAILURE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue