Flash update
This commit is contained in:
@@ -120,7 +120,7 @@ public abstract class APIKeyProtectedHandler extends RequestHandler {
|
||||
Now, your API handler implementation only need to extend APIKeyProtectedHandler, ensuring every request has a valid API key before executing its logic:
|
||||
|
||||
```java
|
||||
@RouteInfo(method = HttpMethod.GET, path = "/data")
|
||||
@RouteInfo(endpoint = "/data", method = HttpMethod.GET)
|
||||
public class GetDataHandler extends APIKeyProtectedHandler {
|
||||
public GetDataHandler(Request req, Response res) {
|
||||
super(req, res);
|
||||
|
||||
@@ -51,7 +51,7 @@ The `ExpectedRequestParameter`, `ExpectedBodyField`, and `ExpectedBodyFile` inst
|
||||
You can use the getter methods to safely get the parameter value, such as `getString`, `getInt`, `getDouble`, and `getBoolean` methods to safely cast the parameter to the expected type.
|
||||
|
||||
```java{4,8,18,21}
|
||||
@RouteInfo(method = HttpMethod.GET, path = "/hello")
|
||||
@RouteInfo(endpoint = "/hello", method = HttpMethod.GET)
|
||||
public class MyHandler extends RequestHandler {
|
||||
// Store the expected parameter in a private field
|
||||
private final ExpectedRequestParameter myExpectedReqParam;
|
||||
@@ -85,7 +85,7 @@ Visiting `/hello?myParam=John` from your browser, will return `Hello, John!`.
|
||||
You can use the getter methods to safely get the field value, such as `getString`, `getInt`, `getDouble`, and `getBoolean` methods to safely cast the field to the expected type.
|
||||
|
||||
```java{4,8,18,21}
|
||||
@RouteInfo(method = HttpMethod.GET, path = "/helloBody")
|
||||
@RouteInfo(endpoint = "/helloBody", method = HttpMethod.GET)
|
||||
public class MyHandler extends RequestHandler {
|
||||
// Store the expected field in a private field
|
||||
private final ExpectedBodyField myExpectedBodyField;
|
||||
@@ -124,7 +124,7 @@ The methods provided by this object are slightly different from the other two, b
|
||||
- `getInputStream()` returns an `InputStream` object containing the file's contents.
|
||||
|
||||
```java{4,8,18,21}
|
||||
@RouteInfo(method = HttpMethod.POST, path = "/helloFile")
|
||||
@RouteInfo(endpoint = "/helloFile", method = HttpMethod.POST)
|
||||
public class MyHandler extends RequestHandler {
|
||||
// Store the expected file in a private field
|
||||
private final ExpectedBodyFile myExpectedBodyFile;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Example {
|
||||
```java{3}
|
||||
// MyHandler.java
|
||||
|
||||
@RouteInfo(method = HttpMethod.GET, path = "/hello")
|
||||
@RouteInfo(endpoint = "/hello", method = HttpMethod.GET)
|
||||
public class MyHandler extends RequestHandler {
|
||||
public MyHandler(Request req, Response res) {
|
||||
super(req, res);
|
||||
|
||||
Reference in New Issue
Block a user