Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class GithubActionsServlet extends HttpServlet {
@Inject
AssistantActions assistantActions;
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//Configure and inject dependencies
DaggerGithubActionsComponent.builder()
.assistantModule(new AssistantModule(response))
.build()
.inject(this);
//Handle call from Google Assistant
assistantActions.handleRequest(parseActionRequest(request));
}
private RootRequest parseActionRequest(HttpServletRequest request) throws IOException {
JsonReader jsonReader = new JsonReader(request.getReader());
return new Gson().fromJson(jsonReader, RootRequest.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment