Skip backend request using plugin backend req/resp modifier

8 views
Skip to first unread message

Alberto Garcia Taravillo

unread,
Apr 25, 2025, 7:06:39 AMApr 25
to KrakenD Community
Hi all,

I'm writing a plugin to skip the backend request based on headers. 

The thing is the only way to stop the krakend pipeline is to throw an error in the request modifier plugin.
Extending KrakenD with Request and Response Plugin Modifiers | KrakenD API Gateway
If a return a 200 - ok with emptybody or a nil,nil the pipeline goes forward to the backend. 

Screenshot 2025-04-25 125730.png

My question is, 
How do I stop the flow/krakend pipeline without returning an error?
My main problem is I see an error in the logs that is not actually an error, it's the desired behaviour, to skip the backend request. 
Documentation does not mention how to skip it. 

Code snippet of current implementation:
        // If no module matches, skip the request and return an empty response
        logger.Debug(fmt.Sprintf("[PLUGIN]: Module '%s' not found in 'Modules' header. Skipping request.", expectedModule))
        return nil, HTTPResponseError{Code: 412, Msg: "Module not needed for backend call"}
// Logs: ▶ DEBUG [PLUGIN]: Module '#postman-1#' not found in 'Modules' header. Skipping request.
2025-04-25 12:52:22 [KRAKEND]  2025/04/25 - 10:52:22.498 ▶ ERROR [ENDPOINT: /v2/:country/home/anonymous] Error #0: Module not needed for backend call
2025-04-25 12:52:22 [GIN] 2025/04/25 - 10:52:22 | 200 |  459.178872ms |      172.18.0.1 | GET      "/v2/ES/home/anonymous"
2025-04-25 12:52:22 Error #01: Module not needed for backend call



Thanks in advance
Reply all
Reply to author
Forward
0 new messages