Class FlashServer
java.lang.Object
com.pixelservices.flash.components.FlashServer
Flash is a highly optimized, asynchronous and multithreaded web server.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final OffHeapBufferPool
static final OffHeapBufferPool
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
after
(String endpoint, SimpleHandler handler) void
afterAfter
(String endpoint, SimpleHandler handler) void
before
(String endpoint, SimpleHandler handler) static void
closeSocket
(AsynchronousSocketChannel clientChannel) void
connect
(String endpoint, SimpleHandler handler) void
delete
(String endpoint, SimpleHandler handler) void
enableCORS
(String allowedOrigins, String allowedMethods, String allowedHeaders) void
get
(String endpoint, SimpleHandler handler) void
head
(String endpoint, SimpleHandler handler) boolean
Checks if the server is currently running.openapi
(String endpoint, OpenAPIConfiguration configuration, OpenAPIUITemplate templateHtml) void
options
(String endpoint, SimpleHandler handler) static RequestInfo
parseRequest
(String rawRequest) void
patch
(String endpoint, SimpleHandler handler) void
post
(String endpoint, SimpleHandler handler) boolean
processMiddleware
(String path, Request request, Response response) void
put
(String endpoint, SimpleHandler handler) void
void
redirect
(String fromPath, String toPath, HttpMethod method) void
registerRoute
(HttpMethod method, String fullPath, RequestHandler handler) void
registerRoute
(HttpMethod method, String fullPath, SimpleHandler handler) void
registerRoute
(HttpMethod method, String fullPath, SimpleHandler handler, HandlerType handlerType) void
serveDynamic
(String endpoint, DynamicFileServerConfiguration config) void
serveDynamic
(String endpoint, DynamicFileServerConfiguration config, Class<?> contextClass) void
serveStatic
(String endpoint, StaticFileServerConfiguration config) start()
Starts the server and binds to the specified port.void
stop()
Stops the server safely.void
trace
(String endpoint, SimpleHandler handler) void
unregisterRoute
(HttpMethod method, String fullPath) void
use
(Middleware middleware) void
use
(String pathPrefix, Middleware middleware) void
ws
(String endpoint, WebSocketHandler handler)
-
Field Details
-
BUFFER_POOL_SIZE
public static final int BUFFER_POOL_SIZE- See Also:
-
BUFFER_SIZE
public static final int BUFFER_SIZE- See Also:
-
REQUEST_BUFFER_POOL
-
WEBSOCKET_BUFFER_SIZE
public static final int WEBSOCKET_BUFFER_SIZE- See Also:
-
WEBSOCKET_BUFFER_POOL
-
-
Constructor Details
-
FlashServer
-
FlashServer
public FlashServer(int port)
-
-
Method Details
-
start
Starts the server and binds to the specified port. This method is non-blocking and returns a thread that can be used to wait for the server to stop.- Returns:
- The thread running the server
-
stop
public void stop()Stops the server safely. This method blocks until the server has fully stopped. -
isRunning
public boolean isRunning()Checks if the server is currently running.- Returns:
- true if the server is running, false otherwise
-
use
-
use
-
enableCORS
-
route
-
registerRoute
-
registerRoute
-
registerRoute
public void registerRoute(HttpMethod method, String fullPath, SimpleHandler handler, HandlerType handlerType) -
unregisterRoute
-
redirect
-
redirect
-
parseRequest
-
processMiddleware
-
closeSocket
-
openapi
public OpenAPISchemaGenerator openapi(String endpoint, OpenAPIConfiguration configuration, OpenAPIUITemplate templateHtml) -
serveStatic
-
serveDynamic
-
serveDynamic
public void serveDynamic(String endpoint, DynamicFileServerConfiguration config, Class<?> contextClass) -
ws
-
get
-
post
-
put
-
delete
-
patch
-
head
-
trace
-
connect
-
options
-
before
-
after
-
afterAfter
-
getRouteHandlers
-
getHandlerPoolManager
-