### Create a Basic Blade Hello World Application Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md This Java code snippet provides a minimal `main` method to bootstrap a Blade web application. It initializes Blade, defines a GET route for the root path ('/'), and responds with 'Hello Blade' text. Running this will start the server, typically on port 9000. ```Java public static void main(String[] args) { Blade.create().get("/", ctx -> ctx.text("Hello Blade")).start(); } ``` -------------------------------- ### Configure SSL properties for INettySslCustomizer Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md This snippet provides example `application.properties` settings required when using a custom `INettySslCustomizer`, including keystore details. ```bash server.ssl.enable=true server.keystore.path=fully qualified path server.keystore.type=PKCS12 server.keystore.password=mypass server.keystore.alias=optional alias ``` -------------------------------- ### Register INettySslCustomizer with Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md This Java snippet demonstrates how to register a custom `INettySslCustomizer` implementation with the Blade application instance before starting it. ```java MyNettySslCustomizer nc = new MyNettySslCustomizer(); Blade.create() .setNettySslCustomizer(nc) .start(App.class, args); } ``` -------------------------------- ### Configure Logging in Blade with SLF4J Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Demonstrates how to use SLF4J for logging in a Blade application. It shows examples of logging messages at different levels: info, warn, debug, and error. ```Java private static final Logger log = LoggerFactory.getLogger(Hello.class); public static void main(String[] args) { log.info("Hello Info, {}", "2017"); log.warn("Hello Warn"); log.debug("Hello Debug"); log.error("Hello Error"); } ``` -------------------------------- ### SLF4J SimpleLogger Configuration Properties Example Source: https://github.com/lets-blade/blade/blob/v2.1.3/blade-core/src/test/resources/log_config.txt An illustrative .properties file showcasing the configurable parameters for SLF4J's SimpleLogger. These settings allow fine-grained control over logging verbosity, output format, and the inclusion of contextual information in log messages. ```Configuration # SLF4J's SimpleLogger configuration file # Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err. # Default logging detail level for all instances of SimpleLogger. # Must be one of ("trace", "debug", "info", "warn", or "error"). # If not specified, defaults to "info". #blade.log.defaultLogLevel=info # Logging detail level for a SimpleLogger instance named "xxxxx". # Must be one of ("trace", "debug", "info", "warn", or "error"). # If not specified, the default logging detail level is used. #blade.log.logger.xxxxx= # Set to true if you want the current date and time to be included in output messages. # Default is false, and will output the number of milliseconds elapsed since startup. #blade.log.showDateTime=false # The date and time format to be used in the output messages. # The pattern describing the date and time format is the same that is used in java.text.SimpleDateFormat. # If the format is not specified or is invalid, the default format is used. # The default format is yyyy-MM-dd HH:mm:ss:SSS Z. #blade.log.dateTimeFormat=yyyy-MM-dd HH:mm:ss:SSS Z # Set to true if you want to output the current thread name. # Defaults to true. #blade.log.showThreadName=true # Set to true if you want the Logger instance name to be included in output messages. # Defaults to true. #blade.log.showLogName=true # Set to true if you want the last component of the name to be included in output messages. # Defaults to false. #blade.log.showShortLogName=false ``` -------------------------------- ### Handle Redirects in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Shows how to implement a server-side redirect in a Blade application using the `ctx.redirect()` method within a route handler. This example redirects to an external URL. ```Java @GET("redirect") public void redirectToGithub(RouteContext ctx){ ctx.redirect("https://github.com/hellokaton"); } ``` -------------------------------- ### Implement Web Hooks in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Explains how to use Blade's `WebHook` interface to intercept requests before or after route execution. The example shows a global `before` hook that prints a message for all incoming requests. ```Java public static void main(String[] args) { // All requests are exported before execution before Blade.create().before("/*", ctx -> { System.out.println("before..."); }).start(); } ``` -------------------------------- ### Write Cookies in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Demonstrates how to set cookies in a Blade application using `ctx.cookie()`. It shows examples of setting a simple key-value cookie and a cookie with an expiration time. ```Java @GET("write-cookie") public void writeCookie(RouteContext ctx){ ctx.cookie("hello", "world"); ctx.cookie("UID", "22", 3600); } ``` -------------------------------- ### Handle Form Parameters in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Demonstrates how to retrieve form parameters using `RouteContext` or the `@Form` annotation in Blade. Includes a `curl` example for testing form data submission. ```java public static void main(String[] args) { Blade.create().get("/user", ctx -> { Integer age = ctx.fromInt("age"); System.out.println("age is:" + age); }).start(); } ``` ```java @POST("/save") public void savePerson(@Form String username, @Form Integer age){ System.out.println("username is:" + username + ", age is:" + age); } ``` ```bash curl -X POST http://127.0.0.1:9000/save -F username=jack -F age=16 ``` -------------------------------- ### Register Routes with Hardcoded Paths in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Demonstrates how to register GET, POST, PUT, and DELETE routes directly using the Blade instance in the main method. This approach hardcodes the paths and their corresponding handlers for simple route definitions. ```java public static void main(String[] args) { // Create multiple routes GET, POST, PUT, DELETE using Blade instance Blade.create() .get("/user/21", getting) .post("/save", posting) .delete("/remove", deleting) .put("/putValue", putting) .start(); } ``` -------------------------------- ### Handle Restful Path Parameters in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Shows how to extract path parameters from URLs using `RouteContext` or the `@PathParam` annotation in Blade. Includes examples for single and multiple path parameters, and a `curl` command for testing. ```java public static void main(String[] args) { Blade blade = Blade.create(); // Create a route: /user/:uid blade.get("/user/:uid", ctx -> { Integer uid = ctx.pathInt("uid"); ctx.text("uid : " + uid); }); // Create two parameters route blade.get("/users/:uid/post/:pid", ctx -> { Integer uid = ctx.pathInt("uid"); Integer pid = ctx.pathInt("pid"); String msg = "uid = " + uid + ", pid = " + pid; ctx.text(msg); }); // Start blade blade.start(); } ``` ```java @GET("/users/:username/:page") public void userTopics(@PathParam String username, @PathParam Integer page){ System.out.println("username is:" + username + ", page is:" + page); } ``` ```bash curl -X GET http://127.0.0.1:9000/users/hellokaton/2 ``` -------------------------------- ### Get Environment Variables in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Demonstrates how to access application environment variables configured in Blade. It retrieves the 'app.version' property, providing a default value if not found. ```java Environment environment = WebContext.blade().environment(); String version = environment.get("app.version", "0.0.1"); ``` -------------------------------- ### Retrieve Request Body Parameters in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Illustrates how to read the entire request body as a string using `RouteContext.bodyToString()` and the `@Body` annotation. A `curl` example demonstrates sending a JSON body to the endpoint. ```java public static void main(String[] args) { Blade.create().post("/body", ctx -> { System.out.println("body string is:" + ctx.bodyToString()); }).start(); } ``` ```java @POST("/body") public void readBody(@Body String data){ System.out.println("data is:" + data); } ``` ```bash curl -X POST http://127.0.0.1:9000/body -d '{"username":"hellokaton","age":22}' ``` -------------------------------- ### Perform CORS GET Request with jQuery Source: https://github.com/lets-blade/blade/blob/v2.1.3/blade-examples/cors.html This JavaScript snippet uses jQuery to perform a GET request to a user-defined URL. It includes logic to add an Authorization Bearer token to the request header if provided. The request uses 'application/x-www-form-urlencoded' content type and alerts 'success' on a successful response. ```JavaScript $("#cors").on('click', function (event) { event.preventDefault(); var url2 = $("#urlText").val(); $.get({ contentType: 'application/x-www-form-urlencoded;charset=UTF-8', url: url2, beforeSend: function (xhr) { if ($("#tokenTxt").val().trim()) { /* Authorization header */ xhr.setRequestHeader("Authorization", "Bearer " + $("#tokenTxt").val()); } }, success: function (data) { alert("success"); } }) }); ``` -------------------------------- ### Read HTTP Headers in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Provides examples for accessing HTTP headers like 'Host', 'User-Agent', and client IP address using `RouteContext` or by injecting specific headers with the `@Header` annotation. ```java @GET("header") public void readHeader(RouteContext ctx){ System.out.println("Host => " + ctx.header("Host")); // get useragent System.out.println("UserAgent => " + ctx.userAgent()); // get client ip System.out.println("Client Address => " + ctx.address()); } ``` ```java @GET("header") public void readHeader(@Header String host){ System.out.println("Host => " + host); } ``` -------------------------------- ### Handle File Uploads in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Demonstrates two methods for handling file uploads in Blade: accessing the `FileItem` from the `Request` object or directly injecting it using the `@Multipart` annotation. Both examples show how to move the uploaded file to a new location. ```java @POST("upload") public void upload(Request request){ request.fileItem("img").ifPresent(fileItem -> { fileItem.moveTo(new File(fileItem.getFileName())); }); } ``` ```java @POST("upload") public void upload(@Multipart FileItem fileItem){ // Save to new path fileItem.moveTo(new File(fileItem.getFileName())); } ``` -------------------------------- ### Handle Request Body Parameters in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Illustrates how to read the request body as a string using `RouteContext.bodyToString()` or by injecting it directly with the `@Body` annotation. A `curl` example demonstrates sending JSON data in the request body. ```java public static void main(String[] args) { Blade.create().post("/body", ctx -> { System.out.println("body string is:" + ctx.bodyToString()); }).start(); } ``` ```java @POST("/body") public void readBody(@Body String data){ System.out.println("data is:" + data); } ``` ```bash curl -X POST http://127.0.0.1:9000/body -d '{"username":"hellokaton","age":22}' ``` -------------------------------- ### Retrieve Path Parameters in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Explains how to capture values directly from URL paths using `RouteContext.pathInt()` for single or multiple parameters, and through the `@PathParam` annotation. Includes a `curl` example for testing path variable extraction. ```java public static void main(String[] args) { Blade blade = Blade.create(); // Create a route: /user/:uid blade.get("/user/:uid", ctx -> { Integer uid = ctx.pathInt("uid"); ctx.text("uid : " + uid); }); // Create two parameters route blade.get("/users/:uid/post/:pid", ctx -> { Integer uid = ctx.pathInt("uid"); Integer pid = ctx.pathInt("pid"); String msg = "uid = " + uid + ", pid = " + pid; ctx.text(msg); }); // Start blade blade.start(); } ``` ```java @GET("/users/:username/:page") public void userTopics(@PathParam String username, @PathParam Integer page){ System.out.println("username is:" + usernam + ", page is:" + page); } ``` ```bash curl -X GET http://127.0.0.1:9000/users/hellokaton/2 ``` -------------------------------- ### Register Routes using Controller Annotations in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Illustrates how to define routes within a controller class using `@Path`, `@GET`, and `@POST` annotations. This method promotes a more structured and modular approach to route management, including handling JSON responses. ```java @Path public class IndexController { @GET("/login") public String login(){ return "login.html"; } @POST(value = "/login", responseType = ResponseType.JSON) public RestResponse doLogin(RouteContext ctx){ // do something return RestResponse.ok(); } } ``` -------------------------------- ### Set HTTP Cookies in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Explains how to set cookies in the HTTP response using `RouteContext.cookie()` in Blade. This includes examples for setting a simple key-value cookie and a cookie with a specified expiration time. ```Java @GET("write-cookie") public void writeCookie(RouteContext ctx){ ctx.cookie("hello", "world"); ctx.cookie("UID", "22", 3600); } ``` -------------------------------- ### Retrieve URL Query Parameters in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Shows two methods for accessing URL query parameters: directly via `RouteContext` and declaratively using the `@Query` annotation. Includes a `curl` example to test the endpoint by sending an 'age' parameter. ```java public static void main(String[] args) { Blade.create().get("/user", ctx -> { Integer age = ctx.queryInt("age"); System.out.println("age is:" + age); }).start(); } ``` ```java @GET("/user") public void savePerson(@Query Integer age){ System.out.println("age is:" + age); } ``` ```bash curl -X GET http://127.0.0.1:9000/user?age=25 ``` -------------------------------- ### Map Request Parameters to Java Objects in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Explains how to automatically map form or body parameters to a Java POJO (Plain Old Java Object) using the `@Form` or `@Body` annotations. Includes examples for custom model names and `curl` commands for testing. ```java public class User { private String username; private Integer age; // getter and setter } ``` ```java @POST("/users") public void saveUser(@Form User user) { System.out.println("user => " + user); } ``` ```bash curl -X POST http://127.0.0.1:9000/users -F username=jack -F age=16 ``` ```java @POST("/users") public void saveUser(@Form(name="u") User user) { System.out.println("user => " + user); } ``` ```bash curl -X POST http://127.0.0.1:9000/users -F u[username]=jack -F u[age]=16 ``` ```java @POST("/body") public void body(@Body User user) { System.out.println("user => " + user); } ``` ```bash curl -X POST http://127.0.0.1:9000/body -d '{"username":"hellokaton","age":22}' ``` -------------------------------- ### Read HTTP Cookies in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Illustrates two ways to read HTTP cookies in Blade: accessing them via the `RouteContext` or directly injecting a specific cookie value using the `@Cookie` annotation. An example shows retrieving a 'UID' cookie. ```java @GET("cookie") public void readCookie(RouteContext ctx){ System.out.println("UID => " + ctx.cookie("UID")); } ``` ```java @GET("cookie") public void readCookie(@Cookie String uid){ System.out.println("Cookie UID => " + uid); } ``` -------------------------------- ### Read HTTP Headers in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Shows two methods to read HTTP request headers in Blade: directly from the `RouteContext` or by injecting a specific header value using the `@Header` annotation. Examples include retrieving Host, User-Agent, and Client IP. ```java @GET("header") public void readHeader(RouteContext ctx){ System.out.println("Host => " + ctx.header("Host")); // get useragent System.out.println("UserAgent => " + ctx.userAgent()); // get client ip System.out.println("Client Address => " + ctx.address()); } ``` ```java @GET("header") public void readHeader(@Header String host){ System.out.println("Host => " + host); } ``` -------------------------------- ### Sample INettySslCustomizer implementation for custom SSL context Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md This Java class provides a sample implementation of `INettySslCustomizer` to create a custom `SslContext` by loading a keystore from application properties. It includes error handling for keystore validation. ```java public class MyNettySSLCustomizer implements INettySslCustomizer { public SslContext getCustomSslContext(Blade blade) { SslContext sslctx = null; // get my custom properties from the environment String keystoreType = blade.getEnv("server.keystore.type", null); String keystorePath = blade.getEnv("server.keystore.path", null); String keystorePass = blade.getEnv("server.keystore.password", null); if (verifyKeystore(keystoreType, keystorePath, keystorePass)) { try (FileInputStream instream = new FileInputStream(new File(keystorePath))) { // verify I can load store and password is valid KeyStore keystore = KeyStore.getInstance(keystoreType); char[] storepw = keystorePass.toCharArray(); keystore.load(instream, storepw); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(keystore, storepw); sslctx = SslContextBuilder.forServer(kmf).build(); } catch (Exception ex) { log.error("Keystore validation failed " + ex.getMessage()); } } else { log.error("Unable to load keystore, sslContext creation failed."); } return sslctx; } ``` -------------------------------- ### Handle File Downloads and Previews in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Demonstrates how to serve files for download (`ResponseType.STREAM`) or for in-browser preview (`ResponseType.PREVIEW`) using `Response.write()`. ```java @GET(value = "/download", responseType = ResponseType.STREAM) public void download(Response response) throws IOException { response.write("abcd.pdf", new File("146373013842336153820220427172437.pdf")); } ``` ```java @GET(value = "/preview", responseType = ResponseType.PREVIEW) public void preview(Response response) throws IOException { response.write(new File("146373013842336153820220427172437.pdf")); } ``` -------------------------------- ### Serve Files for Download or Preview in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Shows how to serve files from a Blade application, either for direct download (`ResponseType.STREAM`) or for in-browser preview (`ResponseType.PREVIEW`). Both methods use `response.write()` to send the file content. ```java @GET(value = "/download", responseType = ResponseType.STREAM) public void download(Response response) throws IOException { response.write("abcd.pdf", new File("146373013842336153820220427172437.pdf")); } ``` ```java @GET(value = "/preview", responseType = ResponseType.PREVIEW) public void preview(Response response) throws IOException { response.write(new File("146373013842336153820220427172437.pdf")); } ``` -------------------------------- ### Configure and Render Jetbrick Template Engine in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Illustrates how to integrate and use the Jetbrick template engine with Blade. It includes configuration via a BladeLoader, passing complex objects (like a User) to the template, and demonstrating conditional logic within the Jetbrick HTML template. ```Java @Bean public class TemplateConfig implements BladeLoader { @Override public void load(Blade blade) { blade.templateEngine(new JetbrickTemplateEngine()); } } ``` ```Java public static void main(String[] args) { Blade.create().get("/hello", ctx -> { User user = new User("hellokaton", 50); ctx.attribute("user", user); ctx.render("hello.html"); }).start(Hello.class, args); } ``` ```HTML
Good Boy!
#elseGooood Baby!
#end ``` -------------------------------- ### Access Environment Configuration in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Demonstrates how to retrieve application environment properties using `WebContext.blade().environment()`. Also shows how to configure static resources via `application.properties`. ```java Environment environment = WebContext.blade().environment(); String version = environment.get("app.version", "0.0.1"); ``` -------------------------------- ### Configure SSL using application.properties Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md This snippet shows basic SSL configuration parameters for `application.properties` in a Blade application, enabling SSL and specifying paths for the certificate and private key. ```bash server.ssl.enable=true server.ssl.cert-path=cert.pem server.ssl.private-key-path=private_key.pem server.ssl.private-key-pass=123456 ``` -------------------------------- ### Configure and Render Default Blade Templates Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Explains how to set up and render templates using Blade's default built-in template engine. By default, template files are expected to be located in the `templates` directory. ```Java public static void main(String[] args) { Blade.create().get("/hello", ctx -> { ctx.attribute("name", "hellokaton"); ctx.render("hello.html"); }).start(Hello.class, args); } ``` ```HTMLGood Boy!
#elseGooood Baby!
#end ``` -------------------------------- ### Implement Basic Authentication in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Shows how to enable basic authentication using Blade's built-in `BasicAuthMiddleware`. It also explains how to configure the username and password in the `application.properties` file. ```Java public static void main(String[] args) { Blade.create().use(new BasicAuthMiddleware()).start(); } ``` ```Bash http.auth.username=admin http.auth.password=123456 ``` -------------------------------- ### Configure and Use Sessions in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Explains how to enable session functionality programmatically or via configuration, and how to store attributes in the session using `Session.attribute()`. ```java Blade.create() .http(HttpOptions::enableSession) .start(Application.class, args); ``` ```properties http.session.enabled=true ``` ```java public void login(Session session){ // if login success session.attribute("login_key", SOME_MODEL); } ``` -------------------------------- ### Configure and Use Logging in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Describes how Blade uses `slf4j-api` as its logging interface, providing a simple default implementation. It demonstrates how to obtain a logger instance and output messages at various log levels (info, warn, debug, error). ```Java private static final Logger log = LoggerFactory.getLogger(Hello.class); public static void main(String[] args) { log.info("Hello Info, {}", "2017"); log.warn("Hello Warn"); log.debug("Hello Debug"); log.error("Hello Error"); } ``` -------------------------------- ### Configure SSL for Blade Server Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Details how to enable and configure SSL for a Blade server using properties in `application.properties`. This includes specifying the certificate path, private key path, and private key password. ```Bash server.ssl.enable=true server.ssl.cert-path=cert.pem server.ssl.private-key-path=private_key.pem server.ssl.private-key-pass=123456 ``` -------------------------------- ### Configure Static Resources in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Explains how to add custom static resource directories programmatically using `Blade.addStatics()` or declaratively in `application.properties`. ```java Blade.create().addStatics("/mydir"); ``` ```properties mvc.statics=/mydir ``` -------------------------------- ### Handle File Uploads in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Illustrates how to process file uploads using `Request.fileItem()` or by directly injecting `FileItem` with the `@Multipart` annotation. Shows how to save the uploaded file. ```java @POST("upload") public void upload(Request request){ request.fileItem("img").ifPresent(fileItem -> { fileItem.moveTo(new File(fileItem.getFileName())); }); } ``` ```java @POST("upload") public void upload(@Multipart FileItem fileItem){ // 保存到新位置 fileItem.moveTo(new File(fileItem.getFileName())); } ``` -------------------------------- ### Blade Response Render API Documentation Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Provides a link to the Javadoc for the `render` method in Blade's `Response` class, which is used for rendering views with a `ModelAndView` object. ```APIDOC http://static.javadoc.io/com.hellokaton/blade-core/2.1.2.RELEASE/com/hellokaton/blade/mvc/http/Response.html#render-com.ModelAndView- ``` -------------------------------- ### Blade Response Redirect API Documentation Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md Provides a link to the Javadoc for the `redirect` method in Blade's `Response` class, used for performing HTTP redirects. ```APIDOC http://static.javadoc.io/com.hellokaton/blade-core/2.1.2.RELEASE/com/hellokaton/blade/mvc/http/Response.html#redirect-java.lang.String- ``` -------------------------------- ### Add Blade Core Dependency with Gradle Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md This line demonstrates how to add the `blade-core` library as a compile-time dependency in your Gradle `build.gradle` file. Place this within the `dependencies` block of your project. ```Gradle compile 'com.hellokaton:blade-core:2.1.2.RELEASE' ``` -------------------------------- ### Implement Route Interceptors (WebHooks) in Blade Source: https://github.com/lets-blade/blade/blob/v2.1.3/README_CN.md Shows how to use Blade's `WebHook` interface to intercept requests before they are executed. This allows for implementing global pre-processing logic or security checks across all routes. ```Java public static void main(String[] args) { // All requests are exported before execution before Blade.create().before("/*", ctx -> { System.out.println("before..."); }).start(); } ``` -------------------------------- ### Add Blade Core Dependency with Maven Source: https://github.com/lets-blade/blade/blob/v2.1.3/README.md This XML snippet shows how to include the `blade-core` library as a dependency in your Maven `pom.xml` file. Ensure you place this within the `