Search in sources :

Example 1 with AppiumStatusAdapter

use of io.appium.espressoserver.lib.model.gsonadapters.AppiumStatusAdapter in project appium-espresso-driver by appium.

the class Server method serve.

@Override
public Response serve(IHTTPSession session) {
    GsonBuilder gsonBuilder = new GsonBuilder().serializeNulls();
    BaseResponse response;
    try {
        response = router.route(session);
    } catch (Exception e) {
        String[] stackTrace = getStackTrace(e);
        response = new ErrorResponse(Response.Status.INTERNAL_ERROR, "Internal error has occurred", stackTrace);
    }
    gsonBuilder.registerTypeAdapter(AppiumStatus.class, new AppiumStatusAdapter());
    return newFixedLengthResponse(response.getHttpStatus(), MediaType.APPLICATION_JSON, gsonBuilder.create().toJson(response));
}
Also used : AppiumStatusAdapter(io.appium.espressoserver.lib.model.gsonadapters.AppiumStatusAdapter) BaseResponse(io.appium.espressoserver.lib.http.response.BaseResponse) GsonBuilder(com.google.gson.GsonBuilder) IOException(java.io.IOException) DuplicateRouteException(io.appium.espressoserver.lib.handlers.exceptions.DuplicateRouteException) ErrorResponse(io.appium.espressoserver.lib.http.response.ErrorResponse)

Aggregations

GsonBuilder (com.google.gson.GsonBuilder)1 DuplicateRouteException (io.appium.espressoserver.lib.handlers.exceptions.DuplicateRouteException)1 BaseResponse (io.appium.espressoserver.lib.http.response.BaseResponse)1 ErrorResponse (io.appium.espressoserver.lib.http.response.ErrorResponse)1 AppiumStatusAdapter (io.appium.espressoserver.lib.model.gsonadapters.AppiumStatusAdapter)1 IOException (java.io.IOException)1