title: Spring Custom Filter to filter response before sending back to client
body: <p>I'm new to the Spring Boot filter</p>
  
  <p>I'need to modify the response produced by the servlet(impl) to some pattern.</p>
  
  <p>For example, 
  <strong>GetProductImpl</strong> will give the response of </p>
  
  <pre><code>{
        "id": 72167,
        "merchantId": 3,
        "amount": 1,
        "state": "Unused"
  }
  </code></pre>
  
  <p>So before it gets to send back to client i need to modify it to (it's kind of put the response under <em>module</em>)(for all response by all servlet)</p>
  
  <pre><code>{
  "module":[{
        "id": 72167,
        "merchantId": 3,
        "amount": 1,
        "state": "Unused"
      }],
  "success":true,
  "errorCode":null,
  "notSuccess":false
  }
  </code></pre>
  
  <p>i looking for any method that can let me do this, because it's no point to do it inside the impl because if like that i need to do for all the impl (which is a lot and not viable). </p>
  
  <p><strong>If anyone have any other method that can achieve this also can because i don't know what approach to take to do this(java example also will do).</strong></p>
  
  <p>Thank you.</p>
  
  <p>My current approach of using filter seems to hit the wall because i using addFilter, addFilterBefore or even addFilterAfter, all of them need to have the out filter class which i don know what it is and focus on web security stuff (<em>UsernamePasswordAuthenticationFilter::class.java</em>).</p>
  
  <pre><code>.addFilterBefore(JWTAuthenticationFilter(tokenAuthenticationService, objectMapper), UsernamePasswordAuthenticationFilter::class.java)
  </code></pre>