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 intstatic final intstatic final OffHeapBufferPoolstatic final OffHeapBufferPoolstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafter(String endpoint, SimpleHandler handler) voidafterAfter(String endpoint, SimpleHandler handler) voidbefore(String endpoint, SimpleHandler handler) static voidcloseSocket(AsynchronousSocketChannel clientChannel) voidconnect(String endpoint, SimpleHandler handler) voiddelete(String endpoint, SimpleHandler handler) voidenableCORS(String allowedOrigins, String allowedMethods, String allowedHeaders) voidget(String endpoint, SimpleHandler handler) voidhead(String endpoint, SimpleHandler handler) booleanChecks if the server is currently running.openapi(String endpoint, OpenAPIConfiguration configuration, OpenAPIUITemplate templateHtml) voidoptions(String endpoint, SimpleHandler handler) static RequestInfoparseRequest(String rawRequest) voidpatch(String endpoint, SimpleHandler handler) voidpost(String endpoint, SimpleHandler handler) booleanprocessMiddleware(String path, Request request, Response response) voidput(String endpoint, SimpleHandler handler) voidvoidredirect(String fromPath, String toPath, HttpMethod method) voidregisterRoute(HttpMethod method, String fullPath, RequestHandler handler) voidregisterRoute(HttpMethod method, String fullPath, SimpleHandler handler) voidregisterRoute(HttpMethod method, String fullPath, SimpleHandler handler, HandlerType handlerType) voidserveDynamic(String endpoint, DynamicFileServerConfiguration config) voidserveDynamic(String endpoint, DynamicFileServerConfiguration config, Class<?> contextClass) voidserveStatic(String endpoint, StaticFileServerConfiguration config) start()Starts the server and binds to the specified port.voidstop()Stops the server safely.voidtrace(String endpoint, SimpleHandler handler) voidunregisterRoute(HttpMethod method, String fullPath) voiduse(Middleware middleware) voiduse(String pathPrefix, Middleware middleware) voidws(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
-