Tabnine Logo
HttpServerResponse.sendNotFound
Code IndexAdd Tabnine to your IDE (free)

How to use
sendNotFound
method
in
reactor.netty.http.server.HttpServerResponse

Best Java code snippets using reactor.netty.http.server.HttpServerResponse.sendNotFound (Showing top 9 results out of 315)

origin: reactor/reactor-netty

@Override
public HttpServerRoutes directory(String uri, Path directory,
    Function<HttpServerResponse, HttpServerResponse> interceptor) {
  Objects.requireNonNull(directory, "directory");
  return route(HttpPredicate.prefix(uri), (req, resp) -> {
    String prefix = URI.create(req.uri())
              .getPath()
              .replaceFirst(uri, "");
    if(prefix.charAt(0) == '/'){
      prefix = prefix.substring(1);
    }
    Path p = directory.resolve(prefix);
    if (Files.isReadable(p)) {
      if (interceptor != null) {
        return interceptor.apply(resp)
                 .sendFile(p);
      }
      return resp.sendFile(p);
    }
    return resp.sendNotFound();
  });
}
origin: io.projectreactor.netty/reactor-netty

@Override
public HttpServerRoutes directory(String uri, Path directory,
    Function<HttpServerResponse, HttpServerResponse> interceptor) {
  Objects.requireNonNull(directory, "directory");
  return route(HttpPredicate.prefix(uri), (req, resp) -> {
    String prefix = URI.create(req.uri())
              .getPath()
              .replaceFirst(uri, "");
    if(prefix.charAt(0) == '/'){
      prefix = prefix.substring(1);
    }
    Path p = directory.resolve(prefix);
    if (Files.isReadable(p)) {
      if (interceptor != null) {
        return interceptor.apply(resp)
                 .sendFile(p);
      }
      return resp.sendFile(p);
    }
    return resp.sendNotFound();
  });
}
origin: reactor/reactor-netty

@Override
public Publisher<Void> apply(HttpServerRequest request, HttpServerResponse response) {
  final Iterator<HttpRouteHandler> iterator = handlers.iterator();
  HttpRouteHandler cursor;
  try {
    while (iterator.hasNext()) {
      cursor = iterator.next();
      if (cursor.test(request)) {
        return cursor.apply(request, response);
      }
    }
  }
  catch (Throwable t) {
    Exceptions.throwIfFatal(t);
    return Mono.error(t); //500
  }
  return response.sendNotFound();
}
origin: io.projectreactor.netty/reactor-netty

@Override
public Publisher<Void> apply(HttpServerRequest request, HttpServerResponse response) {
  final Iterator<HttpRouteHandler> iterator = handlers.iterator();
  HttpRouteHandler cursor;
  try {
    while (iterator.hasNext()) {
      cursor = iterator.next();
      if (cursor.test(request)) {
        return cursor.apply(request, response);
      }
    }
  }
  catch (Throwable t) {
    Exceptions.throwIfFatal(t);
    return Mono.error(t); //500
  }
  return response.sendNotFound();
}
origin: reactor/reactor-netty

/**
 * Listen for WebSocket with the given route predicate to invoke the matching handlers
 *
 * @param condition a predicate given each inbound request
 * @param handler an handler to invoke for the given condition
 * @param protocols sub-protocol to use in WS handshake signature
 *
 * @return a new handler
 */
@SuppressWarnings("unchecked")
default HttpServerRoutes ws(Predicate<? super HttpServerRequest> condition,
    BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>> handler,
    @Nullable String protocols,
    int maxFramePayloadLength) {
  return route(condition, (req, resp) -> {
    if (req.requestHeaders()
        .contains(HttpHeaderNames.CONNECTION, HttpHeaderValues.UPGRADE, true)) {
      HttpServerOperations ops = (HttpServerOperations) req;
      return ops.withWebsocketSupport(req.uri(), protocols, maxFramePayloadLength, handler);
    }
    return resp.sendNotFound();
  });
}
origin: io.projectreactor.netty/reactor-netty

/**
 * Listen for WebSocket with the given route predicate to invoke the matching handlers
 *
 * @param condition a predicate given each inbound request
 * @param handler an handler to invoke for the given condition
 * @param protocols sub-protocol to use in WS handshake signature
 *
 * @return a new handler
 */
@SuppressWarnings("unchecked")
default HttpServerRoutes ws(Predicate<? super HttpServerRequest> condition,
    BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>> handler,
    @Nullable String protocols,
    int maxFramePayloadLength) {
  return route(condition, (req, resp) -> {
    if (req.requestHeaders()
        .contains(HttpHeaderNames.CONNECTION, HttpHeaderValues.UPGRADE, true)) {
      HttpServerOperations ops = (HttpServerOperations) req;
      return ops.withWebsocketSupport(req.uri(), protocols, maxFramePayloadLength, handler);
    }
    return resp.sendNotFound();
  });
}
origin: reactor/reactor-netty

@Test
public void httpPort() {
  DisposableServer blockingFacade = HttpServer.create()
                        .port(8080)
                        .handle((req, resp) -> resp.sendNotFound())
                        .wiretap(true)
                        .bindNow();
  blockingFacade.disposeNow();
  assertThat(blockingFacade.address().getPort())
      .isEqualTo(8080);
}
origin: reactor/reactor-netty

@Test
public void httpPortWithAddress() {
  DisposableServer blockingFacade = HttpServer.create()
                        .port(8080)
                        .host("localhost")
                        .handle((req, resp) -> resp.sendNotFound())
                        .wiretap(true)
                        .bindNow();
  blockingFacade.disposeNow();
  assertThat(blockingFacade.address().getPort())
      .isEqualTo(8080);
}
origin: reactor/reactor-netty

               .validateHeaders(false)
               .initialBufferSize(10))
.handle((req, resp) -> req.receive().then(resp.sendNotFound()))
.tcpConfiguration(tcp ->
    tcp.doOnConnection(c -> {
reactor.netty.http.serverHttpServerResponsesendNotFound

Javadoc

Send 404 status HttpResponseStatus#NOT_FOUND.

Popular methods of HttpServerResponse

  • status
  • send
  • responseHeaders
    Return headers sent back to the clients
  • sendWebsocket
    Upgrade connection to Websocket. Mono and Callback are invoked on handshake success, otherwise the r
  • sendFile
  • header
    Set an outbound header, replacing any pre-existing value.
  • addCookie
    Add an outbound cookie
  • addHeader
    Add an outbound http header, appending the value if the header already exist.
  • alloc
  • sendGroups
  • sendObject
  • sendString
  • sendObject,
  • sendString,
  • chunkedTransfer,
  • compression,
  • headers,
  • options,
  • sendByteArray,
  • sendFileChunked,
  • sendHeaders

Popular in Java

  • Finding current android device location
  • putExtra (Intent)
  • setRequestProperty (URLConnection)
  • addToBackStack (FragmentTransaction)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Menu (java.awt)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JButton (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now