Skip to content

Commit 844bf8d

Browse files
authored
Merge pull request #13 from krakend/sc-553/add-contextregisterer-interface-to-the-plugin
Add the RegisterContext interface method to the modifier plugin to il…
2 parents cab8692 + 0fbf707 commit 844bf8d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

plugins/modifier/modifier.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (r registerer) request(
7474
fmt.Println("query:", req.Query())
7575
fmt.Println("path:", req.Path())
7676

77-
// Return input directly if you don't modify the response
77+
// Return input directly if you don't modify the request
7878
return input, nil
7979
}
8080
}
@@ -218,7 +218,6 @@ func (r responseWrapper) IsComplete() bool { return r.isComplete }
218218
func (r responseWrapper) Io() io.Reader { return r.io }
219219
func (r responseWrapper) Headers() map[string][]string { return r.metadata.headers }
220220
func (r responseWrapper) StatusCode() int { return r.metadata.statusCode }
221-
func (r responseWrapper) Request() interface{} { return r.request }
222221

223222
// This logger is replaced by the RegisterLogger method to load the one from KrakenD
224223
var logger Logger = noopLogger{}
@@ -251,4 +250,13 @@ func (n noopLogger) Error(_ ...interface{}) {}
251250
func (n noopLogger) Critical(_ ...interface{}) {}
252251
func (n noopLogger) Fatal(_ ...interface{}) {}
253252

253+
var ctx = context.Background()
254+
255+
// RegisterContext saves the KrakenD application context so KrakenD can inject
256+
// the context like we do with the logger
257+
func (registerer) RegisterContext(c context.Context) {
258+
ctx = c
259+
logger.Debug(fmt.Sprintf("[PLUGIN: %s] Context loaded", ModifierRegisterer))
260+
}
261+
254262
func main() {}

0 commit comments

Comments
 (0)