Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ type Interface interface {
// CloseReason returns the metadata explaining why a device was closed. If this device
// is not closed, this method's return is undefined.
CloseReason() CloseReason

// IntermediateContext returns any additional information if sent by the device.
IntermediateContext() string
}

// device is the internal Interface implementation. This type holds the internal
Expand All @@ -124,6 +127,8 @@ type device struct {
metadata *Metadata

closeReason atomic.Value

intermediateContext string
}

type deviceOptions struct {
Expand Down Expand Up @@ -320,3 +325,7 @@ func (d *device) CloseReason() CloseReason {

return CloseReason{}
}

func (d *device) IntermediateContext() string {
return d.intermediateContext
}
1 change: 1 addition & 0 deletions device/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func (m *manager) Connect(response http.ResponseWriter, request *http.Request, r
Metadata: metadata,
Logger: m.logger,
})
d.intermediateContext = request.Header.Get("X-Intermediate-Context")

if allow, matchResults := m.filter.AllowConnection(d); !allow {
d.logger.Info("filter match found", zap.String("location", matchResults.Location), zap.String("key", matchResults.Key))
Expand Down
4 changes: 4 additions & 0 deletions device/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ func (m *MockDevice) CloseReason() CloseReason {
return first
}

func (m *MockDevice) IntermediateContext() string {
return ""
}

func (m *MockDevice) Send(request *Request) (*Response, error) {
// nolint: typecheck
arguments := m.Called(request)
Expand Down
Loading