Martian Mod

12 views
Skip to first unread message

Michel Fortes

unread,
Jun 20, 2025, 6:07:48 PMJun 20
to KrakenD Community

Claro! Aqui está a tradução para o inglês em um tom técnico e cordial:


Hello everyone,

I'd just like to double-check something: in the "Martian Modifier", it's not possible to use the same package more than once since it's a map, right?

In the example below, the second "header.Modifier" will overwrite the first one, correct?

"modifier/martian": {
    "header.Modifier": {
        "scope": ["response"],
        "name": "XPTO",
        "value": "some value"
    },
    "header.Modifier": {
        "scope": ["response"],
        "name": "ABC",
        "value": "another value"
    }
}

Best! 

Albert Garcia

unread,
Jun 21, 2025, 4:42:33 AMJun 21
to KrakenD Community, michelp...@gmail.com
Hi Michel,

You are right that in the Martian modifier configuration, a map cannot have duplicate keys, so multiple "header.Modifier" entries will overwrite each other and only the last one takes effect. To apply multiple header modifications or other modifiers, you should use a group modifier such as fifo.Group or priority.Group: https://www.krakend.io/docs/backends/martian/#groups-apply-multiple-modifiers

This will allow you to list several modifiers in order under a modifiers array, each with their own configuration, avoiding key overwrite issues. For example: 

"modifier/martian": {
  "fifo.Group": {
    "scope": ["response"],
    "modifiers": [
      {
        "header.Modifier": {

          "name": "XPTO",
          "value": "some value",
          "scope": ["response"]
        }
      },
      {
        "header.Modifier": {
          "name": "ABC",
          "value": "another value",
          "scope": ["response"]
        }
      }
    ]
  }
}
 
Hope it works!

Michel Fortes

unread,
Jun 21, 2025, 1:48:50 PMJun 21
to KrakenD Community, Albert Garcia, michelp...@gmail.com

Hello, Albert.

Thank you very much for the clarification.
I completely forgot to check the next section of the documentation — precisely the one that would help me with the issue.

Thank you so much for shedding light on this point.

Best!
Reply all
Reply to author
Forward
0 new messages