Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

gatewayFilters

@RefreshScope
@Component
public class AuthenticationFilter implements GatewayFilter {

    final Logger LOGGER = LoggerFactory.getLogger(AuthenticationFilter.class);

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        ServerHttpRequest request = exchange.getRequest();

// Make your business logic, this is a simple sample.


        if (!request.getHeaders().containsKey("x-api-key")) {
            return this.onError(exchange,"api-key missing",HttpStatus.FORBIDDEN);
        }

        return chain.filter(exchange); // Forward to route
    }

    private Mono<Void> onError(ServerWebExchange exchange, String err, HttpStatus httpStatus)  {
        ServerHttpResponse response = exchange.getResponse();
        response.setStatusCode(httpStatus);
        return response.setComplete();
    }
Comment

PREVIOUS NEXT
Code Example
Java :: natural log in java 
Java :: factorial recursion java 
Java :: teimpo en segundos java 
Java :: show menuitem when menu hovered javafx 
Java :: android java how to show progressdialog in fragment 
Java :: session management in java spring boot for login logut 
Java :: intergers are appearing as string in Json 
Java :: how to create a sublist in java 
Java :: android adb is using too much cpu 
Java :: open cv for java 
Java :: how to stop extending jpa repository to every class in java 
Java :: gson to class 
Java :: java stream list order lambda 
Java :: java test coverage 
Java :: Declaration of java list 
Java :: return string consistent of n lowercase letters such is all letters occurs an odd number 
Java :: viewresolver in spring boot 
Java :: Java Boolean Literals 
Java :: Composite foreign keys as primary key jpa 
Java :: os compatible java path separator 
Java :: Sauvegarder une partie en cours dans un fichier texte java 
Java :: The root directory of the External Storage on every android version 
Java :: jlabel text grösse 
Java :: java join if string is empty delimiter not used 
Java :: enum to get status name from list using status id 
Java :: android studio bring keyboard up 
Java :: how to use old android studio project 
Java :: Write a java program to print a number from the user 
Java :: do you have to implement all methods of an interface java 
Java :: IMEI DEVISE ANDROID JAVA 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =