Class ServeStatic
- java.lang.Object
-
- com.github.fmjsjx.libnetty.http.server.middleware.ServeStatic
-
- All Implemented Interfaces:
Middleware,java.util.function.BiFunction<HttpRequestContext,MiddlewareChain,java.util.concurrent.CompletionStage<HttpResult>>
public class ServeStatic extends java.lang.Object implements Middleware
AMiddlewareserves static resources.- Since:
- 1.1
- See Also:
Middleware,MiddlewareChain
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceServeStatic.EtagGeneratorFunction to generatesE-TAGs.static classServeStatic.OptionsThe options ofServeStatic.
-
Constructor Summary
Constructors Constructor Description ServeStatic(ServeStatic.Options options, java.lang.String... pathLocationMappings)Constructs a newServeStaticwith the multiplylocationMappings and the specifiedServeStatic.Options.ServeStatic(java.lang.String path, java.lang.String locationMapping)ServeStatic(java.lang.String path, java.lang.String locationMapping, ServeStatic.Options options)ServeStatic(java.lang.String path1, java.lang.String locationMapping1, java.lang.String path2, java.lang.String locationMapping2, ServeStatic.Options options)Constructs a newServeStaticwith the multiplypaths,locationMappings and the specifiedServeStatic.Options.ServeStatic(java.util.LinkedHashMap<java.lang.String,java.lang.String> locationMappings, ServeStatic.Options options)Constructs a newServeStaticwith the multiplylocationMappings and the specifiedServeStatic.Options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletionStage<HttpResult>apply(HttpRequestContext ctx, MiddlewareChain next)Apply thisMiddlewareto the givenHttpRequestContext.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.fmjsjx.libnetty.http.server.middleware.Middleware
close, onServerClosed
-
-
-
-
Constructor Detail
-
ServeStatic
public ServeStatic(java.lang.String path, java.lang.String locationMapping)- Parameters:
path- the URI prefix pathlocationMapping- the location mapping of the resources
-
ServeStatic
public ServeStatic(java.lang.String path, java.lang.String locationMapping, ServeStatic.Options options)- Parameters:
path- the URI prefix pathlocationMapping- the location mapping of the resourcesoptions- the options
-
ServeStatic
public ServeStatic(java.lang.String path1, java.lang.String locationMapping1, java.lang.String path2, java.lang.String locationMapping2, ServeStatic.Options options)Constructs a newServeStaticwith the multiplypaths,locationMappings and the specifiedServeStatic.Options.- Parameters:
path1- the first URI prefix pathlocationMapping1- the first location mapping of the resourcespath2- the second URI prefix pathlocationMapping2- the second location mapping of the resourcesoptions- the options
-
ServeStatic
public ServeStatic(ServeStatic.Options options, java.lang.String... pathLocationMappings)
Constructs a newServeStaticwith the multiplylocationMappings and the specifiedServeStatic.Options.- Parameters:
options- the optionspathLocationMappings- the array contains the URI prefix paths and the location mappings, the length of array must be even
-
ServeStatic
public ServeStatic(java.util.LinkedHashMap<java.lang.String,java.lang.String> locationMappings, ServeStatic.Options options)Constructs a newServeStaticwith the multiplylocationMappings and the specifiedServeStatic.Options.- Parameters:
locationMappings- the map contains the URI prefix paths and the location mappingsoptions- the options
-
-
Method Detail
-
apply
public java.util.concurrent.CompletionStage<HttpResult> apply(HttpRequestContext ctx, MiddlewareChain next)
Description copied from interface:MiddlewareApply thisMiddlewareto the givenHttpRequestContext.- Specified by:
applyin interfacejava.util.function.BiFunction<HttpRequestContext,MiddlewareChain,java.util.concurrent.CompletionStage<HttpResult>>- Specified by:
applyin interfaceMiddleware- Parameters:
ctx- theHttpRequestContextobject of the current HTTP requestnext- theMiddlewareChainfor invoking the nextMiddleware- Returns:
- a
CompletionStage<HttpResult>
-
-