Skip to content

Commit 0c75577

Browse files
authored
golang-http: update example to adapt latest break change (#99)
For behavior change: Change ``OnLogDownstreamStart``, ``OnLogDownstreamPeriodic`` and ``OnLog`` methods so that user can get the request/response's headers and trailers when producing access log. Signed-off-by: spacewander <[email protected]>
1 parent 2f14068 commit 0c75577

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

golang-http/simple/filter.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (f *filter) EncodeTrailers(trailers api.ResponseTrailerMap) api.StatusType
9595
}
9696

9797
// OnLog is called when the HTTP stream is ended on HTTP Connection Manager filter.
98-
func (f *filter) OnLog() {
98+
func (f *filter) OnLog(reqHeader api.RequestHeaderMap, reqTrailer api.RequestTrailerMap, respHeader api.ResponseHeaderMap, respTrailer api.ResponseTrailerMap) {
9999
code, _ := f.callbacks.StreamInfo().ResponseCode()
100100
respCode := strconv.Itoa(int(code))
101101
api.LogDebug(respCode)
@@ -121,13 +121,13 @@ func (f *filter) OnLog() {
121121

122122
// OnLogDownstreamStart is called when HTTP Connection Manager filter receives a new HTTP request
123123
// (required the corresponding access log type is enabled)
124-
func (f *filter) OnLogDownstreamStart() {
124+
func (f *filter) OnLogDownstreamStart(reqHeader api.RequestHeaderMap) {
125125
// also support kicking off a goroutine here, like OnLog.
126126
}
127127

128128
// OnLogDownstreamPeriodic is called on any HTTP Connection Manager periodic log record
129129
// (required the corresponding access log type is enabled)
130-
func (f *filter) OnLogDownstreamPeriodic() {
130+
func (f *filter) OnLogDownstreamPeriodic(reqHeader api.RequestHeaderMap, reqTrailer api.RequestTrailerMap, respHeader api.ResponseHeaderMap, respTrailer api.ResponseTrailerMap) {
131131
// also support kicking off a goroutine here, like OnLog.
132132
}
133133

golang-http/simple/go.mod

+1-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ go 1.20
66
// NOTICE: these lines could be generated automatically by "go mod tidy"
77
require (
88
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa
9-
github.com/envoyproxy/envoy v1.24.0
9+
github.com/envoyproxy/envoy v1.31.1-0.20240821014141-c8f58b61c36d
1010
google.golang.org/protobuf v1.34.2
1111
)
1212

@@ -16,8 +16,3 @@ require (
1616
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect
1717
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
1818
)
19-
20-
// TODO: remove when #26173 lands.
21-
// And check the "API compatibility" section in doc:
22-
// https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/golang_filter#developing-a-go-plugin
23-
replace github.com/envoyproxy/envoy => ../../..

golang-http/simple/go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ=
22
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM=
3+
github.com/envoyproxy/envoy v1.31.1-0.20240821014141-c8f58b61c36d h1:YwwhqKB3CuEDpN2gjj8ed+ptgTgSP9EZ7mWe7WdLgMM=
4+
github.com/envoyproxy/envoy v1.31.1-0.20240821014141-c8f58b61c36d/go.mod h1:ujBFxE543X8OePZG+FbeR9LnpBxTLu64IAU7A20EB9A=
35
github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA=
46
github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE=
57
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=

0 commit comments

Comments
 (0)