Example usage for org.springframework.web.reactive.function.server ServerRequest queryParam

List of usage examples for org.springframework.web.reactive.function.server ServerRequest queryParam

Introduction

In this page you can find the example usage for org.springframework.web.reactive.function.server ServerRequest queryParam.

Prototype

default Optional<String> queryParam(String name) 

Source Link

Document

Get the first query parameter with the given name, if present.

Usage

From source file:com.example.message.GetMessageRequest.java

static GetMessageRequest create(final ServerRequest request) {
    final Integer page = request.queryParam("page").map(Integer::parseInt).orElse(0);
    final Integer size = request.queryParam("size").map(Integer::parseInt).orElse(20);
    return new GetMessageRequest(page, size);
}

From source file:com.example.TestEndpoint.java

Mono<ServerResponse> test(final ServerRequest request) {
    final Optional<String> value = request.queryParam("value");
    return Mono.justOrEmpty(value).map(Wrapper::new)
            .flatMap(v -> ServerResponse.ok().body(Mono.just(v), Wrapper.class))
            .switchIfEmpty(ServerResponse.notFound().build());
}

From source file:org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler.java

/**
 * Check whether the trace attribute has been set on the given request.
 * @param request the source request//from w  w w  . j  av a 2  s.  c om
 * @return {@code true} if the error trace has been requested, {@code false} otherwise
 */
protected boolean isTraceEnabled(ServerRequest request) {
    String parameter = request.queryParam("trace").orElse("false");
    return !"false".equalsIgnoreCase(parameter);
}