In our Main class, we need to instantiate new ClassProvider and pass it to the ServerImpl:
In our ServerImpl constructor, we only need to pass the ClassProvider to our ServerRouteConfigImpl:
This is it. The next thing we need to edit is the HttpHandler.
15.Changing the Http Handler
Our handle() method currently isn't working, but we don't care about that for now. First, we want to create a new method called fillTypeConversions(), which will parse our parameters. Create new private field holding Map>:
Call this method in your constructor. Now we can take a look at handle().
First, delete the for loop that iterate over non-existing collection:
In the same place call the setFunction() of the RequestHandlemImpl:
This function will be relatively long, so get ready. We want to get our method, the current URL and the parameters positions in the URL:
Now we want to parse our parameters, that we are receiving from the URL:
We are using our typeConversions function to parse the current parameter. Finally, we want to invoke our method and get the HttpResponse it returns. Then we return that response to our function:
Now we should be able to start our server again. Before we do that, let's add a route.
|