@Override
    public void handleRequest(final HttpServerExchange exchange) throws Exception {

        // handle request header
        Map<String, Object> requestHeaderMap = (Map<String, Object>)config.get(REQUEST);
        if(requestHeaderMap != null) {
            List<String> requestHeaderRemove = (List<String>)requestHeaderMap.get(REMOVE);
            if(requestHeaderRemove != null) {
                requestHeaderRemove.forEach(s -> exchange.getRequestHeaders().remove(s));
            }
            Map<String, String> requestHeaderUpdate = (Map<String, String>)requestHeaderMap.get(UPDATE);
            if(requestHeaderUpdate != null) {
                requestHeaderUpdate.forEach((k, v) -> exchange.getRequestHeaders().put(new HttpString(k), v));
            }
        }

        // handle response header
        Map<String, Object> responseHeaderMap = (Map<String, Object>)config.get(RESPONSE);
        if(responseHeaderMap != null) {
            List<String> responseHeaderRemove = (List<String>)responseHeaderMap.get(REMOVE);
            if(responseHeaderRemove != null) {
                responseHeaderRemove.forEach(s -> exchange.getResponseHeaders().remove(s));
            }
            Map<String, String> responseHeaderUpdate = (Map<String, String>)responseHeaderMap.get(UPDATE);
            if(responseHeaderUpdate != null) {
                responseHeaderUpdate.forEach((k, v) -> exchange.getResponseHeaders().put(new HttpString(k), v));
            }
        }
        Handler.next(exchange, next);
    }
@ Override public void handleRequest ( final HttpServerExchange exchange ) throws Exception { Map < String , Object > requestHeaderMap = ( Map < String , Object > ) config . get ( REQUEST ) ; if ( requestHeaderMap != null ) { List < String > requestHeaderRemove = ( List < String > ) requestHeaderMap . get ( REMOVE ) ; if ( requestHeaderRemove != null ) { requestHeaderRemove . forEach ( s -> exchange . getRequestHeaders ( ) . remove ( s ) ) ; } Map < String , String > requestHeaderUpdate = ( Map < String , String > ) requestHeaderMap . get ( UPDATE ) ; if ( requestHeaderUpdate != null ) { requestHeaderUpdate . forEach ( ( k , v ) -> exchange . getRequestHeaders ( ) . put ( new HttpString ( k ) , v ) ) ; } } Map < String , Object > responseHeaderMap = ( Map < String , Object > ) config . get ( RESPONSE ) ; if ( responseHeaderMap != null ) { List < String > responseHeaderRemove = ( List < String > ) responseHeaderMap . get ( REMOVE ) ; if ( responseHeaderRemove != null ) { responseHeaderRemove . forEach ( s -> exchange . getResponseHeaders ( ) . remove ( s ) ) ; } Map < String , String > responseHeaderUpdate = ( Map < String , String > ) responseHeaderMap . get ( UPDATE ) ; if ( responseHeaderUpdate != null ) { responseHeaderUpdate . forEach ( ( k , v ) -> exchange . getResponseHeaders ( ) . put ( new HttpString ( k ) , v ) ) ; } } Handler . next ( exchange , next ) ; }
Check iterate the configuration on both request and response section and update
headers accordingly.

@param exchange HttpServerExchange
@throws Exception Exception