diff --git a/404.html b/404.html index fdfded4..da6ff81 100644 --- a/404.html +++ b/404.html @@ -17,7 +17,7 @@
- + \ No newline at end of file diff --git a/assets/banner-cards/flash-advanced-fullstack-development.md.png b/assets/banner-cards/flash-advanced-fullstack-development.md.png new file mode 100644 index 0000000..5935a1f Binary files /dev/null and b/assets/banner-cards/flash-advanced-fullstack-development.md.png differ diff --git a/assets/banner-cards/flash-advanced-handler-default-implementations.md.png b/assets/banner-cards/flash-advanced-handler-default-implementations.md.png new file mode 100644 index 0000000..f8c2a64 Binary files /dev/null and b/assets/banner-cards/flash-advanced-handler-default-implementations.md.png differ diff --git a/assets/banner-cards/flash-core-concepts-handlers.md.png b/assets/banner-cards/flash-core-concepts-handlers.md.png new file mode 100644 index 0000000..b4cc349 Binary files /dev/null and b/assets/banner-cards/flash-core-concepts-handlers.md.png differ diff --git a/assets/banner-cards/flash-core-concepts-request-handler.md.png b/assets/banner-cards/flash-core-concepts-request-handler.md.png new file mode 100644 index 0000000..53396a1 Binary files /dev/null and b/assets/banner-cards/flash-core-concepts-request-handler.md.png differ diff --git a/assets/banner-cards/flash-core-concepts-request-response.md.png b/assets/banner-cards/flash-core-concepts-request-response.md.png new file mode 100644 index 0000000..e656495 Binary files /dev/null and b/assets/banner-cards/flash-core-concepts-request-response.md.png differ diff --git a/assets/banner-cards/flash-core-concepts-server-router.md.png b/assets/banner-cards/flash-core-concepts-server-router.md.png new file mode 100644 index 0000000..4c6b457 Binary files /dev/null and b/assets/banner-cards/flash-core-concepts-server-router.md.png differ diff --git a/assets/banner-cards/flash-core-concepts-websockets.md.png b/assets/banner-cards/flash-core-concepts-websockets.md.png new file mode 100644 index 0000000..48337c4 Binary files /dev/null and b/assets/banner-cards/flash-core-concepts-websockets.md.png differ diff --git a/assets/banner-cards/flash-file-serving-dynamic-file-server.md.png b/assets/banner-cards/flash-file-serving-dynamic-file-server.md.png new file mode 100644 index 0000000..7ad888c Binary files /dev/null and b/assets/banner-cards/flash-file-serving-dynamic-file-server.md.png differ diff --git a/assets/banner-cards/flash-file-serving-static-file-server.md.png b/assets/banner-cards/flash-file-serving-static-file-server.md.png new file mode 100644 index 0000000..4512122 Binary files /dev/null and b/assets/banner-cards/flash-file-serving-static-file-server.md.png differ diff --git a/assets/banner-cards/flash-index.md.png b/assets/banner-cards/flash-index.md.png new file mode 100644 index 0000000..56f422a Binary files /dev/null and b/assets/banner-cards/flash-index.md.png differ diff --git a/assets/banner-cards/flash-introduction-installation.md.png b/assets/banner-cards/flash-introduction-installation.md.png new file mode 100644 index 0000000..d81d7e0 Binary files /dev/null and b/assets/banner-cards/flash-introduction-installation.md.png differ diff --git a/assets/banner-cards/mobot-index.md.png b/assets/banner-cards/mobot-index.md.png new file mode 100644 index 0000000..7e57532 Binary files /dev/null and b/assets/banner-cards/mobot-index.md.png differ diff --git a/assets/banner-cards/serverlibraries-index.md.png b/assets/banner-cards/serverlibraries-index.md.png new file mode 100644 index 0000000..548921c Binary files /dev/null and b/assets/banner-cards/serverlibraries-index.md.png differ diff --git a/assets/flash_core-concepts_handlers.md.B1156l1I.js b/assets/flash_core-concepts_handlers.md.B1156l1I.js new file mode 100644 index 0000000..35a29cd --- /dev/null +++ b/assets/flash_core-concepts_handlers.md.B1156l1I.js @@ -0,0 +1 @@ +import{_ as a,c as s,a0 as t,o as n}from"./chunks/framework.p2VkXzrt.js";const u=JSON.parse('{"title":"📚 Handlers","description":"","frontmatter":{"banner-title":"Flash - Handlers","banner-description":"Learn about handlers in Flash and the different types available.","head":[["meta",{"name":"twitter:image","content":"/assets/banner-cards/flash-core-concepts-handlers.png"}],["meta",{"name":"twitter:image:src","content":"https://docs.pixel-services.com/assets/banner-cards/flash-core-concepts-handlers.png"}],["meta",{"name":"twitter:card","content":"summary_large_image"}],["meta",{"name":"twitter:image:height","content":"1280"}],["meta",{"name":"twitter:image:width","content":"669"}],["meta",{"name":"twitter:description","content":""}]]},"headers":[],"relativePath":"flash/core-concepts/handlers.md","filePath":"flash/core-concepts/handlers.md"}'),i={name:"flash/core-concepts/handlers.md"};function r(l,e,o,h,d,c){return n(),s("div",null,e[0]||(e[0]=[t('

📚 Handlers

In Flash, handlers are the building blocks of your application logic. They are responsible for processing incoming requests, executing the necessary logic, and generating the appropriate response.

There are several types of handlers in Flash, each serving a specific purpose and providing a different level of control over the request lifecycle. Understanding the different handler types will help you structure your application logic more effectively and make the most out of Flash's powerful routing system.

📦 Routing Behavior

Before diving into the different handler types, it's essential to understand how routing works in Flash. When a request is received by the server, Flash matches the request path and method against the registered routes to find the appropriate handler. The handler is then executed, and its response is sent back to the client.

Flash supports 3 main types of routing behaviors:

📌 Handler Types

1. RequestHandler

The RequestHandler is the "standard" type of handler in Flash, it provides the most control over the request lifecycle and allows you to define custom logic for handling requests. You can extend the RequestHandler class to create custom handlers that process incoming requests and generate responses.

Because RequestHandler is an abstract class, you need to implement both the handle() method and the super constructor in your custom handler to define the logic that should be executed when a request is received.

Since RequestHandler is an abstract class, you can leverage and chain HDI's to create cleaner and more maintainable route logic (more on that in the Handler Default Implementations guide).

java
\n### 2. SimpleHandler\n\nThe `SimpleHandler` is a lightweight handler that allows you to define request handling logic in a single method using lambda notation.\nIt is useful for simple request processing tasks that don't require the full lifecycle control provided by `RequestHandler`.\n\nTo create a `SimpleHandler`, you can use the `server.get()`, `server.post()`, `server.put()`, `server.delete()` etc.\nin general, you can use the `server.<METHOD>()` methods to register the handler with the server.\n\nThe arguments for these methods are the route path and a lambda expression that provides\nthe request and response objects and defines the request handling logic.\n\n```java[Example]\nserver.get("/hello", (req, res) -> {\n    return "Hello, World!";\n});

Both RequestHandler and SimpleHandler can specify the router behavior by the naming convention of the endpoint used to register the handler.

',16)]))}const g=a(i,[["render",r]]);export{u as __pageData,g as default}; diff --git a/assets/flash_core-concepts_handlers.md.B1156l1I.lean.js b/assets/flash_core-concepts_handlers.md.B1156l1I.lean.js new file mode 100644 index 0000000..35a29cd --- /dev/null +++ b/assets/flash_core-concepts_handlers.md.B1156l1I.lean.js @@ -0,0 +1 @@ +import{_ as a,c as s,a0 as t,o as n}from"./chunks/framework.p2VkXzrt.js";const u=JSON.parse('{"title":"📚 Handlers","description":"","frontmatter":{"banner-title":"Flash - Handlers","banner-description":"Learn about handlers in Flash and the different types available.","head":[["meta",{"name":"twitter:image","content":"/assets/banner-cards/flash-core-concepts-handlers.png"}],["meta",{"name":"twitter:image:src","content":"https://docs.pixel-services.com/assets/banner-cards/flash-core-concepts-handlers.png"}],["meta",{"name":"twitter:card","content":"summary_large_image"}],["meta",{"name":"twitter:image:height","content":"1280"}],["meta",{"name":"twitter:image:width","content":"669"}],["meta",{"name":"twitter:description","content":""}]]},"headers":[],"relativePath":"flash/core-concepts/handlers.md","filePath":"flash/core-concepts/handlers.md"}'),i={name:"flash/core-concepts/handlers.md"};function r(l,e,o,h,d,c){return n(),s("div",null,e[0]||(e[0]=[t('

📚 Handlers

In Flash, handlers are the building blocks of your application logic. They are responsible for processing incoming requests, executing the necessary logic, and generating the appropriate response.

There are several types of handlers in Flash, each serving a specific purpose and providing a different level of control over the request lifecycle. Understanding the different handler types will help you structure your application logic more effectively and make the most out of Flash's powerful routing system.

📦 Routing Behavior

Before diving into the different handler types, it's essential to understand how routing works in Flash. When a request is received by the server, Flash matches the request path and method against the registered routes to find the appropriate handler. The handler is then executed, and its response is sent back to the client.

Flash supports 3 main types of routing behaviors:

📌 Handler Types

1. RequestHandler

The RequestHandler is the "standard" type of handler in Flash, it provides the most control over the request lifecycle and allows you to define custom logic for handling requests. You can extend the RequestHandler class to create custom handlers that process incoming requests and generate responses.

Because RequestHandler is an abstract class, you need to implement both the handle() method and the super constructor in your custom handler to define the logic that should be executed when a request is received.

Since RequestHandler is an abstract class, you can leverage and chain HDI's to create cleaner and more maintainable route logic (more on that in the Handler Default Implementations guide).

java
\n### 2. SimpleHandler\n\nThe `SimpleHandler` is a lightweight handler that allows you to define request handling logic in a single method using lambda notation.\nIt is useful for simple request processing tasks that don't require the full lifecycle control provided by `RequestHandler`.\n\nTo create a `SimpleHandler`, you can use the `server.get()`, `server.post()`, `server.put()`, `server.delete()` etc.\nin general, you can use the `server.<METHOD>()` methods to register the handler with the server.\n\nThe arguments for these methods are the route path and a lambda expression that provides\nthe request and response objects and defines the request handling logic.\n\n```java[Example]\nserver.get("/hello", (req, res) -> {\n    return "Hello, World!";\n});

Both RequestHandler and SimpleHandler can specify the router behavior by the naming convention of the endpoint used to register the handler.

',16)]))}const g=a(i,[["render",r]]);export{u as __pageData,g as default}; diff --git a/assets/flash_file-serving_dynamic-file-server.md.DY_r4ecH.js b/assets/flash_file-serving_dynamic-file-server.md.DY_r4ecH.js new file mode 100644 index 0000000..7d4b4a6 --- /dev/null +++ b/assets/flash_file-serving_dynamic-file-server.md.DY_r4ecH.js @@ -0,0 +1,28 @@ +import{_ as i,c as a,a0 as e,o as n}from"./chunks/framework.p2VkXzrt.js";const c=JSON.parse('{"title":"📁 Dynamic File Server","description":"","frontmatter":{"banner_title":"Flash - Dynamic File Server","banner_description":"Learn how to serve files in a dynamic context.","head":[["meta",{"name":"twitter:image","content":"/assets/banner-cards/flash-file-serving-dynamic-file-server.png"}],["meta",{"name":"twitter:image:src","content":"https://docs.pixel-services.com/assets/banner-cards/flash-file-serving-dynamic-file-server.png"}],["meta",{"name":"twitter:card","content":"summary_large_image"}],["meta",{"name":"twitter:image:height","content":"1280"}],["meta",{"name":"twitter:image:width","content":"669"}],["meta",{"name":"twitter:description","content":""}]]},"headers":[],"relativePath":"flash/file-serving/dynamic-file-server.md","filePath":"flash/file-serving/dynamic-file-server.md"}'),t={name:"flash/file-serving/dynamic-file-server.md"};function l(h,s,p,r,k,d){return n(),a("div",null,s[0]||(s[0]=[e(`

📁 Dynamic File Server

Sometimes we need to serve files in a dynamic context, in this sense a static file server is limiting. Imagine we have a frontend application that is compiled down to a single index.html file, and we want to serve it with Flash alongside it's javascript and css bundles. The way these compiled applications work is that they rely heavily on client-side routing, so when the user navigates to a different page, the frontend application will try to fetch the corresponding file from the server. This is where a dynamic file server comes in handy, as no route is pre-registered.

WARNING

The dynamic file server relies heavily on the concept of dynamic handlers, which are handlers that will resolve for any subpath of the endpoint they are registered to (see Handler Types for more info).

Usage

To serve static files in Flash, you need to call the server.serveDynamic() method with the endpoint path and an instance of DynamicFileServerConfig. The configuration object is instanced like so :

java
DynamicFileServerConfiguration(
+    boolean enableFileWatcher,
+    String destinationPath,
+    String dynamicEntrypoint,
+    SourceType sourceType
+)

Registering the dynamic file server is as simple as calling the server.serveDynamic() method with the desired path and configuration object:

java
public class Example {
+    public static void main(String[] args) {
+        FlashServer server = new FlashServer(8080);
+
+        server.serveDynamic("/*", new DynamicFileServerConfiguration(
+            true,
+            "path/to/my/files",
+            "index.html",
+            SourceType.FILESYSTEM
+        ));
+    }
+}

Now you can access the files (or frontend) in the specified directory by navigating to http://localhost:8080/<file-name>.

Similarly, you can serve the same content from the jar's resources folder by setting the sourceType to RESOURCESTREAM:

java
public class Example {
+    public static void main(String[] args) {
+        FlashServer server = new FlashServer(8080);
+
+        server.serveStatic("/static", new DynamicFileServerConfiguration(
+            true,
+            "path/to/my/files",
+            "index.html",
+            SourceType.RESOURCESTREAM
+        ));
+    }
+}
`,12)]))}const E=i(t,[["render",l]]);export{c as __pageData,E as default}; diff --git a/assets/flash_file-serving_dynamic-file-server.md.DY_r4ecH.lean.js b/assets/flash_file-serving_dynamic-file-server.md.DY_r4ecH.lean.js new file mode 100644 index 0000000..7d4b4a6 --- /dev/null +++ b/assets/flash_file-serving_dynamic-file-server.md.DY_r4ecH.lean.js @@ -0,0 +1,28 @@ +import{_ as i,c as a,a0 as e,o as n}from"./chunks/framework.p2VkXzrt.js";const c=JSON.parse('{"title":"📁 Dynamic File Server","description":"","frontmatter":{"banner_title":"Flash - Dynamic File Server","banner_description":"Learn how to serve files in a dynamic context.","head":[["meta",{"name":"twitter:image","content":"/assets/banner-cards/flash-file-serving-dynamic-file-server.png"}],["meta",{"name":"twitter:image:src","content":"https://docs.pixel-services.com/assets/banner-cards/flash-file-serving-dynamic-file-server.png"}],["meta",{"name":"twitter:card","content":"summary_large_image"}],["meta",{"name":"twitter:image:height","content":"1280"}],["meta",{"name":"twitter:image:width","content":"669"}],["meta",{"name":"twitter:description","content":""}]]},"headers":[],"relativePath":"flash/file-serving/dynamic-file-server.md","filePath":"flash/file-serving/dynamic-file-server.md"}'),t={name:"flash/file-serving/dynamic-file-server.md"};function l(h,s,p,r,k,d){return n(),a("div",null,s[0]||(s[0]=[e(`

📁 Dynamic File Server

Sometimes we need to serve files in a dynamic context, in this sense a static file server is limiting. Imagine we have a frontend application that is compiled down to a single index.html file, and we want to serve it with Flash alongside it's javascript and css bundles. The way these compiled applications work is that they rely heavily on client-side routing, so when the user navigates to a different page, the frontend application will try to fetch the corresponding file from the server. This is where a dynamic file server comes in handy, as no route is pre-registered.

WARNING

The dynamic file server relies heavily on the concept of dynamic handlers, which are handlers that will resolve for any subpath of the endpoint they are registered to (see Handler Types for more info).

Usage

To serve static files in Flash, you need to call the server.serveDynamic() method with the endpoint path and an instance of DynamicFileServerConfig. The configuration object is instanced like so :

java
DynamicFileServerConfiguration(
+    boolean enableFileWatcher,
+    String destinationPath,
+    String dynamicEntrypoint,
+    SourceType sourceType
+)

Registering the dynamic file server is as simple as calling the server.serveDynamic() method with the desired path and configuration object:

java
public class Example {
+    public static void main(String[] args) {
+        FlashServer server = new FlashServer(8080);
+
+        server.serveDynamic("/*", new DynamicFileServerConfiguration(
+            true,
+            "path/to/my/files",
+            "index.html",
+            SourceType.FILESYSTEM
+        ));
+    }
+}

Now you can access the files (or frontend) in the specified directory by navigating to http://localhost:8080/<file-name>.

Similarly, you can serve the same content from the jar's resources folder by setting the sourceType to RESOURCESTREAM:

java
public class Example {
+    public static void main(String[] args) {
+        FlashServer server = new FlashServer(8080);
+
+        server.serveStatic("/static", new DynamicFileServerConfiguration(
+            true,
+            "path/to/my/files",
+            "index.html",
+            SourceType.RESOURCESTREAM
+        ));
+    }
+}
`,12)]))}const E=i(t,[["render",l]]);export{c as __pageData,E as default}; diff --git a/flash/advanced/fullstack-development.html b/flash/advanced/fullstack-development.html index 1521280..97b7f7d 100644 --- a/flash/advanced/fullstack-development.html +++ b/flash/advanced/fullstack-development.html @@ -54,7 +54,7 @@ server.start(); } }

🚀 Package and Deploy your app!

With the frontend and backend code in place, you can now build the JAR file and deploy it to your server. The JAR file will contain both the frontend and backend code, making it easy to deploy and run your fullstack application.

All you've left to do is run the jarfile on any machine that has Java installed, and your fullstack application will be up and running!

- + \ No newline at end of file diff --git a/flash/advanced/handler-default-implementations.html b/flash/advanced/handler-default-implementations.html index 34d97de..da4ab90 100644 --- a/flash/advanced/handler-default-implementations.html +++ b/flash/advanced/handler-default-implementations.html @@ -118,7 +118,7 @@ return "{\"username\":\"" + username + "\"}"; } } - + \ No newline at end of file diff --git a/flash/core-concepts/handlers.html b/flash/core-concepts/handlers.html index 80a7695..87eb123 100644 --- a/flash/core-concepts/handlers.html +++ b/flash/core-concepts/handlers.html @@ -13,7 +13,7 @@ - + @@ -25,10 +25,23 @@ -
Skip to content

📚 Handlers

In Flash, handlers are the building blocks of your application logic. They are responsible for processing incoming requests, executing the necessary logic, and generating the appropriate response.

There are several types of handlers in Flash, each serving a specific purpose and providing a different level of control over the request lifecycle. Understanding the different handler types will help you structure your application logic more effectively and make the most out of Flash's powerful routing system.

📦 Routing Behavior

Before diving into the different handler types, it's essential to understand how routing works in Flash. When a request is received by the server, Flash matches the request path and method against the registered routes to find the appropriate handler. The handler is then executed, and its response is sent back to the client.

Flash supports 3 main types of routing behaviors:

  • Literal Routing: Matches the exact path specified in the route definition.
  • Parametrized Routing: Matches paths with dynamic segments that are extracted as route parameters.
  • Dynamic Routing: Matches any path that starts with the specified prefix and is flagged with a wildcard "*" character.

📌 Handler Types

1. RequestHandler

The RequestHandler is the "standard" type of handler in Flash, it provides the most control over the request lifecycle and allows you to define custom logic for handling requests. You can extend the RequestHandler class to create custom handlers that process incoming requests and generate responses.

Because RequestHandler is an abstract class, you need to implement both the handle() method and the super constructor in your custom handler to define the logic that should be executed when a request is received.

Since RequestHandler is an abstract class, you can leverage and chain HDI's to create cleaner and more maintainable route logic (more on that in the Handler Default Implementations section).

2. SimpleHandler

The SimpleHandler is a lightweight handler that allows you to define request handling logic in a single method using lambda notation. It is useful for simple request processing tasks that don't require the full lifecycle control provided by RequestHandler.

To create a SimpleHandler, you can use the server.get(), server.post(), server.put(), server.delete() etc. in general, you can use the server.<METHOD>() methods to register the handler with the server.

The arguments for these methods are the route path and a lambda expression that provides the request and response objects and defines the request handling logic.

java
server.get("/hello", (req, res) -> {
-    return "Hello, World!";
-});

Both RequestHandler and SimpleHandler can specify the router behavior by the naming convention of the endpoint used to register the handler.

  • Literal Routing: /hello
    Will match exactly /hello

  • Parametrized Routing: /hello/:name
    Will match /hello/John, /hello/Alice, etc.

  • Dynamic Routing: /hello/*
    Will match /hello/../..

- +
Skip to content

📚 Handlers

In Flash, handlers are the building blocks of your application logic. They are responsible for processing incoming requests, executing the necessary logic, and generating the appropriate response.

There are several types of handlers in Flash, each serving a specific purpose and providing a different level of control over the request lifecycle. Understanding the different handler types will help you structure your application logic more effectively and make the most out of Flash's powerful routing system.

📦 Routing Behavior

Before diving into the different handler types, it's essential to understand how routing works in Flash. When a request is received by the server, Flash matches the request path and method against the registered routes to find the appropriate handler. The handler is then executed, and its response is sent back to the client.

Flash supports 3 main types of routing behaviors:

  • Literal Routing: Matches the exact path specified in the route definition.
  • Parametrized Routing: Matches paths with dynamic segments that are extracted as route parameters.
  • Dynamic Routing: Matches any path that starts with the specified prefix and is flagged with a wildcard "*" character.

📌 Handler Types

1. RequestHandler

The RequestHandler is the "standard" type of handler in Flash, it provides the most control over the request lifecycle and allows you to define custom logic for handling requests. You can extend the RequestHandler class to create custom handlers that process incoming requests and generate responses.

Because RequestHandler is an abstract class, you need to implement both the handle() method and the super constructor in your custom handler to define the logic that should be executed when a request is received.

Since RequestHandler is an abstract class, you can leverage and chain HDI's to create cleaner and more maintainable route logic (more on that in the Handler Default Implementations guide).

java

+### 2. SimpleHandler
+
+The `SimpleHandler` is a lightweight handler that allows you to define request handling logic in a single method using lambda notation.
+It is useful for simple request processing tasks that don't require the full lifecycle control provided by `RequestHandler`.
+
+To create a `SimpleHandler`, you can use the `server.get()`, `server.post()`, `server.put()`, `server.delete()` etc.
+in general, you can use the `server.<METHOD>()` methods to register the handler with the server.
+
+The arguments for these methods are the route path and a lambda expression that provides
+the request and response objects and defines the request handling logic.
+
+```java[Example]
+server.get("/hello", (req, res) -> {
+    return "Hello, World!";
+});

Both RequestHandler and SimpleHandler can specify the router behavior by the naming convention of the endpoint used to register the handler.

  • Literal Routing: /hello
    Will match exactly /hello

  • Parametrized Routing: /hello/:name
    Will match /hello/John, /hello/Alice, etc.

  • Dynamic Routing: /hello/*
    Will match /hello/../..

+ \ No newline at end of file diff --git a/flash/core-concepts/request-handler.html b/flash/core-concepts/request-handler.html index 316b403..8fa8559 100644 --- a/flash/core-concepts/request-handler.html +++ b/flash/core-concepts/request-handler.html @@ -37,7 +37,7 @@ return response; } }

WARNING

Any logic that needs to be executed before the request handler is registered must be done within the constructor.

Request Handler methods

The RequestHandler class provides several methods that can be used to interact with the request and response objects easily and safely. Following are listed the methods available in the RequestHandler class, with a brief description of their purpose:

MethodParamsDescription
getRequestBody()noneReturns a JSONObject representation of the request body.
getSpecification()noneReturns an instance of HandlerSpecification containing all sorts of information about the handler.
expectedRequestParameter()String name, descriptionReturns an instance of ExpectedRequestParameter for the specified parameter name.
expectedBodyField()String name, descriptionReturns an instance of ExpectedBodyField for the specified field name.
expectedBodyFile()String name, descriptionReturns an instance of ExpectedBodyFile for the specified file name.

(More on the ExpectedRequestParameter, ExpectedBodyField, and ExpectedBodyFile classes in the next section).

- + \ No newline at end of file diff --git a/flash/core-concepts/request-response.html b/flash/core-concepts/request-response.html index e43d81e..a739f47 100644 --- a/flash/core-concepts/request-response.html +++ b/flash/core-concepts/request-response.html @@ -92,7 +92,7 @@ return "File saved at: " + myFile.getAbsolutePath(); } }

This time, you will need to use a tool like Postman to send a POST request to /helloFile with a multipart form data body containing a file named myFile. You should receive a response like File saved at: <path> where <path> is the location where the server saved the file.

- + \ No newline at end of file diff --git a/flash/core-concepts/server-router.html b/flash/core-concepts/server-router.html index dfa9b2b..5f8f991 100644 --- a/flash/core-concepts/server-router.html +++ b/flash/core-concepts/server-router.html @@ -49,7 +49,7 @@ return response; } }

In the example above, we create an /api router and register the MyHandler class to handle requests on the /api/hello endpoint.

This is because the path property of the RouteInfo annotation is relative to the base path of the router, which in this case is /api.

Visiting /api/hello from your browser will result in the response Hello, world!.

- + \ No newline at end of file diff --git a/flash/core-concepts/websockets.html b/flash/core-concepts/websockets.html index 20b4b56..880d505 100644 --- a/flash/core-concepts/websockets.html +++ b/flash/core-concepts/websockets.html @@ -58,7 +58,7 @@ server.start(); } }

Interacting with Websockets sessions

The WebSocketSession object provides methods to interact with the Websocket session, such as sending messages, closing the connection, and getting the remote address and session ID.

MethodParamsDescription
getChannel()noneReturns an instance of AsynchronousSocketChannel useful for retrieving info about the client .
getRequestInfo()noneReturns an instance of RequestInfo containing all sorts of information about the request (headers, method, path etc.) .
getPath()noneReturns the path to the websocket endpoint as a String.
getId()noneReturns the id of the websocket session as a String, useful if you want to keep track of the connected clients in a custom manager.
getBuffer()noneReturns the ByteBuffer for that session.
sendMessage()String messageSends the message to the client as a String. it's up to the developer to stringify and de-stringify any data you want to send back and forth
close()noneCloses the websocket session.

NOTE

WebsocketHandler includes a setId(String id) method for overriding the default session ID. Unless you have a specific reason to change it, it's best to leave it as is.

Similarly, the setBuffer(ByteBuffer buffer) method allows you to override the default buffer. If you're unsure about this, it's recommended to keep the default setting.

- + \ No newline at end of file diff --git a/flash/file-serving/dynamic-file-server.html b/flash/file-serving/dynamic-file-server.html index 0754576..d46b462 100644 --- a/flash/file-serving/dynamic-file-server.html +++ b/flash/file-serving/dynamic-file-server.html @@ -13,7 +13,7 @@ - + @@ -25,7 +25,7 @@ -
Skip to content

📁 Dynamic File Server

Sometimes we need to serve files in a dynamic context, in this sense a static file server is limiting. Imagine we have a frontend application that is compiled down to a single index.html file, and we want to serve it with Flash alongside it's javascript and css bundles. The way these compiled applications work is that they rely heavily on client-side routing, so when the user navigates to a different page, the frontend application will try to fetch the corresponding file from the server. This is where a dynamic file server comes in handy, as no route is pre-registered.

WARNING

The dynamic file server relies heavily on the concept of dynamic handlers, which are handlers that will resolve for any subpath of the endpoint they are registered to (see Handler Types for more info).

Usage

To serve static files in Flash, you need to call the server.serveDynamic() method with the endpoint path and an instance of DynamicFileServerConfig. The configuration object is instanced like so :

java
DynamicFileServerConfiguration(
+    
Skip to content

📁 Dynamic File Server

Sometimes we need to serve files in a dynamic context, in this sense a static file server is limiting. Imagine we have a frontend application that is compiled down to a single index.html file, and we want to serve it with Flash alongside it's javascript and css bundles. The way these compiled applications work is that they rely heavily on client-side routing, so when the user navigates to a different page, the frontend application will try to fetch the corresponding file from the server. This is where a dynamic file server comes in handy, as no route is pre-registered.

WARNING

The dynamic file server relies heavily on the concept of dynamic handlers, which are handlers that will resolve for any subpath of the endpoint they are registered to (see Handler Types for more info).

Usage

To serve static files in Flash, you need to call the server.serveDynamic() method with the endpoint path and an instance of DynamicFileServerConfig. The configuration object is instanced like so :

java
DynamicFileServerConfiguration(
     boolean enableFileWatcher,
     String destinationPath,
     String dynamicEntrypoint,
@@ -53,7 +53,7 @@
         ));
     }
 }
- + \ No newline at end of file diff --git a/flash/file-serving/static-file-server.html b/flash/file-serving/static-file-server.html index 993e1ab..92f0e92 100644 --- a/flash/file-serving/static-file-server.html +++ b/flash/file-serving/static-file-server.html @@ -53,7 +53,7 @@ )); } }
- + \ No newline at end of file diff --git a/flash/index.html b/flash/index.html index c0457f1..85e2b76 100644 --- a/flash/index.html +++ b/flash/index.html @@ -26,7 +26,7 @@
Skip to content

⚡ Flash

Flash is a simple, modern and fast expressive web framework written in Java. The project is maintained by Pixel Services and the open-source community.

Our Team

Say hello to the Pixel Services team !

Relism

Relism

Developer

Sieadev

Sieadev

Developer

- + \ No newline at end of file diff --git a/flash/introduction/installation.html b/flash/introduction/installation.html index 6dc5ec7..bb8fee0 100644 --- a/flash/introduction/installation.html +++ b/flash/introduction/installation.html @@ -44,7 +44,7 @@ }
  • And the dependency :

    groovy
    dependencies {
         implementation 'com.pixelservices:flash:{{ latestVersion }}'
     }
  • ⚡ Latest version:
    - + \ No newline at end of file diff --git a/hashmap.json b/hashmap.json index 1929c03..73ed51d 100644 --- a/hashmap.json +++ b/hashmap.json @@ -1 +1 @@ -{"flash_advanced_fullstack-development.md":"B124NtWL","flash_advanced_handler-default-implementations.md":"BSoFk9xD","flash_core-concepts_handlers.md":"ChVWECmb","flash_core-concepts_request-handler.md":"fjZWLpOw","flash_core-concepts_request-response.md":"3C-3EYgj","flash_core-concepts_server-router.md":"BtmNSZRo","flash_core-concepts_websockets.md":"ByGVX96c","flash_file-serving_dynamic-file-server.md":"BxDWqJ2P","flash_file-serving_static-file-server.md":"BvN0FZB2","flash_index.md":"E5zPbZtg","flash_introduction_installation.md":"BEOKwAAp","index.md":"CgmTRI0Q","mobot_index.md":"Be0Zoetq","serverlibraries_index.md":"CeIqSPIs"} +{"flash_advanced_fullstack-development.md":"B124NtWL","flash_advanced_handler-default-implementations.md":"BSoFk9xD","flash_core-concepts_handlers.md":"B1156l1I","flash_core-concepts_request-handler.md":"fjZWLpOw","flash_core-concepts_request-response.md":"3C-3EYgj","flash_core-concepts_server-router.md":"BtmNSZRo","flash_core-concepts_websockets.md":"ByGVX96c","flash_file-serving_dynamic-file-server.md":"DY_r4ecH","flash_file-serving_static-file-server.md":"BvN0FZB2","flash_index.md":"E5zPbZtg","flash_introduction_installation.md":"BEOKwAAp","index.md":"CgmTRI0Q","mobot_index.md":"Be0Zoetq","serverlibraries_index.md":"CeIqSPIs"} diff --git a/index.html b/index.html index ffec7ca..2e90c3b 100644 --- a/index.html +++ b/index.html @@ -26,7 +26,7 @@
    Skip to content
    - + \ No newline at end of file diff --git a/mobot/index.html b/mobot/index.html index f6f2b90..9378216 100644 --- a/mobot/index.html +++ b/mobot/index.html @@ -26,7 +26,7 @@
    Skip to content
    - + \ No newline at end of file diff --git a/serverlibraries/index.html b/serverlibraries/index.html index 44d9d2d..a471d2a 100644 --- a/serverlibraries/index.html +++ b/serverlibraries/index.html @@ -26,7 +26,7 @@
    Skip to content
    - + \ No newline at end of file