Created
May 11, 2017 20:36
-
-
Save frogermcs/7355dcde7ccd51f9a2db6d1869f8dd2b to your computer and use it in GitHub Desktop.
This file contains 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
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