Created
May 21, 2019 13:41
-
-
Save Fleker/5859a67fdded40639e31e5fd1801982e to your computer and use it in GitHub Desktop.
Springboot implementation for Action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SpringBootApplication | |
public class ActionsApplication { | |
private static final Logger LOG = LoggerFactory.getLogger(SillyNameMakerApp.class); | |
private final App actionsApp = new SillyNameMakerApp(); | |
@RestController | |
class ActionsController { | |
@GetMapping("/") | |
String serveAck() { | |
return "App is listening but requires valid POST request to respond with Action response."; | |
} | |
@RequestMapping(value = "/", method = RequestMethod.POST, produces = { "application/json" }) | |
String serveAction(@RequestBody String body, @RequestHeader Map<String, String> headers) { | |
try { | |
return actionsApp.handleRequest(body, headers).get(); | |
} catch (InterruptedException | ExecutionException e) { | |
return handleError(e); | |
} | |
} | |
private String handleError(Exception e) { | |
e.printStackTrace(); | |
LOG.error("Error in app.handleRequest ", e); | |
return "Error handling the intent - " + e.getMessage(); | |
} | |
} | |
public static void main(String[] args) { | |
SpringApplication.run(ActionsApplication.class, args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment