com.devsmart.miniweb.handlers.controller.ControllerInvoker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of miniweb-core Show documentation
Show all versions of miniweb-core Show documentation
Miniweb is an embedded webserver for Java.
package com.devsmart.miniweb.handlers.controller;
import com.google.gson.Gson;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.entity.StringEntity;
import org.apache.http.protocol.HTTP;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpRequestHandler;
import com.devsmart.miniweb.utils.RequestMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.lang.reflect.Method;
public class ControllerInvoker implements HttpRequestHandler {
public final Logger logger = LoggerFactory.getLogger(ControllerInvoker.class);
public PathVarCapture pathEndpoint;
public Object instance;
public Method method;
public ParamHandler[] paramHandlers;
public boolean serializeRetval;
private Gson mGson;
public RequestMethod requestMethod;
public String pathPrefix;
public ControllerInvoker(Gson gson) {
mGson = gson;
}
private Gson getGson() {
return mGson;
}
@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException {
Object[] params = new Object[paramHandlers.length];
for(int i=0;i