Top Description Inners Fields Constructors Methods
reactor.netty.http.server

pack-priv final Class DefaultHttpServerRoutes

extends Object
implements HttpServerRoutes
Class Inheritance
All Implemented Interfaces
reactor.netty.http.server.HttpServerRoutes, java.util.function.BiFunction
Imports
java.net.URI, java.nio.file.Files, .Path, java.util.ArrayList, .Comparator, .Iterator, .List, .Map, .Objects, java.util.concurrent.CopyOnWriteArrayList, java.util.function.BiFunction, .Function, .Predicate, io.netty.handler.codec.http.HttpMethod, org.reactivestreams.Publisher, reactor.core.Exceptions, reactor.core.publisher.Mono, reactor.util.annotation.Nullable

Server routes are unique and only the first matching in order of declaration will be invoked.
Author
Stephane Maldini

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private Comparator<HttpRouteHandlerMetadata>
private final CopyOnWriteArrayList<DefaultHttpServerRoutes.HttpRouteHandler>
private final List<DefaultHttpServerRoutes.HttpRouteHandler>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Publisher<Void>
apply(HttpServerRequest
the first function argument
request
,
HttpServerResponse
the second function argument
response
)

Implements java.util.function.BiFunction.apply.

Applies this function to the given arguments.
public HttpServerRoutes
comparator(Comparator<HttpRouteHandlerMetadata>
a HttpRouteHandlerMetadata comparator.
comparator
)

Implements reactor.netty.http.server.HttpServerRoutes.comparator.

Use the provided java.util.Comparator to sort routes, rather than using configured order.Routes that were already configured are also impacted by this change and will be sorted according to the comparator.You can revert to using the declaration order by calling the noComparator() method (which is the default).
public HttpServerRoutes
directory(String
The GET path used by clients
uri
,
Path
the root prefix to serve from the file system, e.g. "/Users/me/resources"
directory
,
Function<HttpServerResponse, HttpServerResponse>
a pre response processor
interceptor
)

Implements reactor.netty.http.server.HttpServerRoutes.directory.

Listens for HTTP GET on the passed path to be used as a routing condition.The content of the provided directory will be served.
public HttpServerRoutes
noComparator()

Implements reactor.netty.http.server.HttpServerRoutes.noComparator.

Removes any previously applied java.util.Comparator customization using HttpServerRoutes#comparator(Comparator), and use the order in which the routes were configured.
public HttpServerRoutes
removeIf(Predicate<? super HttpRouteHandlerMetadata>
a predicate given each http route handler HttpRouteHandlerMetadata
condition
)

Implements reactor.netty.http.server.HttpServerRoutes.removeIf.

A generic route predicate that if matched already register I/O handler use HttpServerRoutes#route(Predicate, BiFunction) will be removed.
public HttpServerRoutes
route(Predicate<? super HttpServerRequest>
a predicate given each inbound request
condition
,
BiFunction<? super HttpServerRequest, ? super HttpServerResponse, ? extends Publisher<Void>>
the I/O handler to invoke on match
handler
)

Implements reactor.netty.http.server.HttpServerRoutes.route.

A generic route predicate that if matched invoke the passed I/O handler.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

comparatorback to summary
private Comparator<HttpRouteHandlerMetadata> comparator
handlersback to summary
private final CopyOnWriteArrayList<DefaultHttpServerRoutes.HttpRouteHandler> handlers
initialOrderHandlersback to summary
private final List<DefaultHttpServerRoutes.HttpRouteHandler> initialOrderHandlers

Constructor Detail

DefaultHttpServerRoutesback to summary
pack-priv DefaultHttpServerRoutes()

Method Detail

applyback to summary
public Publisher<Void> apply(HttpServerRequest request, HttpServerResponse response)

Implements java.util.function.BiFunction.apply.

Doc from java.util.function.BiFunction.apply.

Applies this function to the given arguments.

Parameters
request:HttpServerRequest

the first function argument

response:HttpServerResponse

the second function argument

Returns:Publisher<Void>

the function result

Annotations
@Override
comparatorback to summary
public HttpServerRoutes comparator(Comparator<HttpRouteHandlerMetadata> comparator)

Implements reactor.netty.http.server.HttpServerRoutes.comparator.

Doc from reactor.netty.http.server.HttpServerRoutes.comparator.

Use the provided java.util.Comparator to sort routes, rather than using configured order.Routes that were already configured are also impacted by this change and will be sorted according to the comparator.You can revert to using the declaration order by calling the noComparator() method (which is the default).

Parameters
comparator:Comparator<HttpRouteHandlerMetadata>

a HttpRouteHandlerMetadata comparator.

Returns:HttpServerRoutes

this HttpServerRoutes

Annotations
@Override
directoryback to summary
public HttpServerRoutes directory(String uri, Path directory, Function<HttpServerResponse, HttpServerResponse> interceptor)

Implements reactor.netty.http.server.HttpServerRoutes.directory.

Doc from reactor.netty.http.server.HttpServerRoutes.directory.

Listens for HTTP GET on the passed path to be used as a routing condition.The content of the provided directory will be served.

Additional regex matching is available, e.g. "/test/{param}". Params are resolved using HttpServerRequest#param(CharSequence)

Parameters
uri:String

The GET path used by clients

directory:Path

the root prefix to serve from the file system, e.g. "/Users/me/resources"

interceptor:Function<HttpServerResponse, HttpServerResponse>

a pre response processor

Returns:HttpServerRoutes

this HttpServerRoutes

Annotations
@Override
noComparatorback to summary
public HttpServerRoutes noComparator()

Implements reactor.netty.http.server.HttpServerRoutes.noComparator.

Doc from reactor.netty.http.server.HttpServerRoutes.noComparator.

Removes any previously applied java.util.Comparator customization using HttpServerRoutes#comparator(Comparator), and use the order in which the routes were configured.

Returns:HttpServerRoutes

this HttpServerRoutes

Annotations
@Override
removeIfback to summary
public HttpServerRoutes removeIf(Predicate<? super HttpRouteHandlerMetadata> condition)

Implements reactor.netty.http.server.HttpServerRoutes.removeIf.

Doc from reactor.netty.http.server.HttpServerRoutes.removeIf.

A generic route predicate that if matched already register I/O handler use HttpServerRoutes#route(Predicate, BiFunction) will be removed.

Parameters
condition:Predicate<? super HttpRouteHandlerMetadata>

a predicate given each http route handler HttpRouteHandlerMetadata

Returns:HttpServerRoutes

this HttpServerRoutes

Annotations
@Override
routeback to summary
public HttpServerRoutes route(Predicate<? super HttpServerRequest> condition, BiFunction<? super HttpServerRequest, ? super HttpServerResponse, ? extends Publisher<Void>> handler)

Implements reactor.netty.http.server.HttpServerRoutes.route.

Doc from reactor.netty.http.server.HttpServerRoutes.route.

A generic route predicate that if matched invoke the passed I/O handler.

Parameters
condition:Predicate<? super HttpServerRequest>

a predicate given each inbound request

handler:BiFunction<? super HttpServerRequest, ? super HttpServerResponse, ? extends Publisher<Void>>

the I/O handler to invoke on match

Returns:HttpServerRoutes

this HttpServerRoutes

Annotations
@Override
reactor.netty.http.server back to summary

pack-priv final Class DefaultHttpServerRoutes.HttpRouteHandler

extends Object
implements BiFunction<HttpServerRequest, HttpServerResponse, Publisher<Void>>, Predicate<HttpServerRequest>, HttpRouteHandlerMetadata
Class Inheritance
  • java.lang.Object
  • reactor.netty.http.server.DefaultHttpServerRoutes.HttpRouteHandler
All Implemented Interfaces
reactor.netty.http.server.HttpRouteHandlerMetadata, java.util.function.Predicate, java.util.function.BiFunction

Field Summary

Modifier and TypeField and Description
pack-priv final Predicate<? super HttpServerRequest>
pack-priv final BiFunction<? super HttpServerRequest, ? super HttpServerResponse, ? extends Publisher<Void>>
pack-priv final HttpMethod
pack-priv final String
pack-priv final Function<? super String, Map<String, String>>

Constructor Summary

AccessConstructor and Description
pack-priv
HttpRouteHandler(Predicate<? super HttpServerRequest> condition, BiFunction<? super HttpServerRequest, ? super HttpServerResponse, ? extends Publisher<Void>> handler, Function<? super String, Map<String, String>> resolver, String path, HttpMethod method)

Method Summary

Modifier and TypeMethod and Description
public Publisher<Void>
apply(HttpServerRequest
the first function argument
request
,
HttpServerResponse
the second function argument
response
)

Implements java.util.function.BiFunction.apply.

Applies this function to the given arguments.
public HttpMethod
getMethod()

Implements reactor.netty.http.server.HttpRouteHandlerMetadata.getMethod.

Get the http method this handler can handle.
public String
getPath()

Implements reactor.netty.http.server.HttpRouteHandlerMetadata.getPath.

Get the http path this handler can handle.
public boolean
test(HttpServerRequest
the input argument
o
)

Implements java.util.function.Predicate.test.

Evaluates this predicate on the given argument.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

conditionback to summary
pack-priv final Predicate<? super HttpServerRequest> condition
handlerback to summary
pack-priv final BiFunction<? super HttpServerRequest, ? super HttpServerResponse, ? extends Publisher<Void>> handler
methodback to summary
pack-priv final HttpMethod method
pathback to summary
pack-priv final String path
resolverback to summary
pack-priv final Function<? super String, Map<String, String>> resolver

Constructor Detail

HttpRouteHandlerback to summary
pack-priv HttpRouteHandler(Predicate<? super HttpServerRequest> condition, BiFunction<? super HttpServerRequest, ? super HttpServerResponse, ? extends Publisher<Void>> handler, Function<? super String, Map<String, String>> resolver, String path, HttpMethod method)

Method Detail

applyback to summary
public Publisher<Void> apply(HttpServerRequest request, HttpServerResponse response)

Implements java.util.function.BiFunction.apply.

Doc from java.util.function.BiFunction.apply.

Applies this function to the given arguments.

Parameters
request:HttpServerRequest

the first function argument

response:HttpServerResponse

the second function argument

Returns:Publisher<Void>

the function result

Annotations
@Override
getMethodback to summary
public HttpMethod getMethod()

Implements reactor.netty.http.server.HttpRouteHandlerMetadata.getMethod.

Doc from reactor.netty.http.server.HttpRouteHandlerMetadata.getMethod.

Get the http method this handler can handle.

Returns:HttpMethod

the http method HttpMethod

Annotations
@Override
getPathback to summary
public String getPath()

Implements reactor.netty.http.server.HttpRouteHandlerMetadata.getPath.

Doc from reactor.netty.http.server.HttpRouteHandlerMetadata.getPath.

Get the http path this handler can handle.

Returns:String

the http path

Annotations
@Override
testback to summary
public boolean test(HttpServerRequest o)

Implements java.util.function.Predicate.test.

Doc from java.util.function.Predicate.test.

Evaluates this predicate on the given argument.

Parameters
o:HttpServerRequest

the input argument

Returns:boolean

true if the input argument matches the predicate, otherwise false

Annotations
@Override