code update recorded at: 17/04/26 09:33:57
This commit is contained in:
commit
0b693fad07
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.boltic.io.serverless;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class Handler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the incoming request and returns a JSON response.
|
||||||
|
*
|
||||||
|
* @return ResponseEntity containing the JSON response or an error message.
|
||||||
|
*/
|
||||||
|
public ResponseEntity<String> handler(String method, String requestBody) {
|
||||||
|
try {
|
||||||
|
// Prepare the response JSON
|
||||||
|
String responseJson = "{\"message\": \"Hello World\"}";
|
||||||
|
|
||||||
|
// Print the JSON response to stdout
|
||||||
|
System.out.println(responseJson);
|
||||||
|
|
||||||
|
// Return the response with HTTP status 200 (OK)
|
||||||
|
return ResponseEntity.ok().body(responseJson);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Handle errors by printing the stack trace
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
// Return an error response with HTTP status 500 (Internal Server Error)
|
||||||
|
return ResponseEntity.status(500).body("Internal Server Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user