Skip to content

Commit 9fb6bf1

Browse files
committed
Update to API v4 and fix stream endpoints
1 parent e0cdc4b commit 9fb6bf1

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
NGINX_PLUS_VERSION=17-1
1+
NGINX_PLUS_VERSION=18-1
22
NGINX_IMAGE=nginxplus:$(NGINX_PLUS_VERSION)
33

44
test: docker-build run-nginx-plus test-run configure-no-stream-block test-run-no-stream-block clean
@@ -14,14 +14,16 @@ run-nginx-plus:
1414

1515
test-run:
1616
go test client/*
17-
GOCACHE=off go test tests/client_test.go
17+
go clean -testcache
18+
go test tests/client_test.go
1819

1920
configure-no-stream-block:
2021
docker cp docker/nginx_no_stream.conf nginx-plus-test:/etc/nginx/nginx.conf
2122
docker exec nginx-plus-test nginx -s reload
2223

2324
test-run-no-stream-block:
24-
GOCACHE=off go test tests/client_no_stream_test.go
25+
go clean -testcache
26+
go test tests/client_no_stream_test.go
2527

2628
clean:
2729
docker kill nginx-plus-test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This project includes a client library for working with NGINX Plus API.
1111

1212
## Compatibility
1313

14-
This Client works against version 2 of NGINX Plus API. Version 2 was introduced in NGINX Plus R14.
14+
This Client works against version 4 of NGINX Plus API. Version 4 was introduced in NGINX Plus R18.
1515

1616
## Using the Client
1717

client/nginx.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
)
1111

1212
// APIVersion is a version of NGINX Plus API.
13-
const APIVersion = 2
13+
const APIVersion = 4
1414

15-
const streamNotConfiguredCode = "StreamNotConfigured"
15+
const pathNotFoundCode = "PathNotFound"
1616

1717
const streamContext = true
1818
const httpContext = false
@@ -44,16 +44,14 @@ type StreamUpstreamServer struct {
4444
}
4545

4646
type apiErrorResponse struct {
47-
Path string
48-
Method string
4947
Error apiError
5048
RequestID string `json:"request_id"`
5149
Href string
5250
}
5351

5452
func (resp *apiErrorResponse) toString() string {
55-
return fmt.Sprintf("path=%v; method=%v; error.status=%v; error.text=%v; error.code=%v; request_id=%v; href=%v",
56-
resp.Path, resp.Method, resp.Error.Status, resp.Error.Text, resp.Error.Code, resp.RequestID, resp.Href)
53+
return fmt.Sprintf("error.status=%v; error.text=%v; error.code=%v; request_id=%v; href=%v",
54+
resp.Error.Status, resp.Error.Text, resp.Error.Code, resp.RequestID, resp.Href)
5755
}
5856

5957
type apiError struct {
@@ -792,7 +790,7 @@ func (client *NginxClient) getStreamServerZones() (*StreamServerZones, error) {
792790
err := client.get("stream/server_zones", &zones)
793791
if err != nil {
794792
if err, ok := err.(*internalError); ok {
795-
if err.Code == streamNotConfiguredCode {
793+
if err.Code == pathNotFoundCode {
796794
return &zones, nil
797795
}
798796
}
@@ -815,7 +813,7 @@ func (client *NginxClient) getStreamUpstreams() (*StreamUpstreams, error) {
815813
err := client.get("stream/upstreams", &upstreams)
816814
if err != nil {
817815
if err, ok := err.(*internalError); ok {
818-
if err.Code == streamNotConfiguredCode {
816+
if err.Code == pathNotFoundCode {
819817
return &upstreams, nil
820818
}
821819
}

0 commit comments

Comments
 (0)