Skip to content

Instantly share code, notes, and snippets.

@frogermcs
Created May 11, 2017 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frogermcs/7355dcde7ccd51f9a2db6d1869f8dd2b to your computer and use it in GitHub Desktop.
Save frogermcs/7355dcde7ccd51f9a2db6d1869f8dd2b to your computer and use it in GitHub Desktop.
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