Skip to content

Instantly share code, notes, and snippets.

@Fleker
Created May 21, 2019 13:41
Show Gist options
  • Save Fleker/5859a67fdded40639e31e5fd1801982e to your computer and use it in GitHub Desktop.
Save Fleker/5859a67fdded40639e31e5fd1801982e to your computer and use it in GitHub Desktop.
Springboot implementation for Action
@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