Search in sources :

Example 21 with ApiResponse

use of io.apiman.gateway.engine.beans.ApiResponse in project apiman-plugins by apiman.

the class ProduceXmlBackEndApi method invoke.

@Override
public PolicyTestBackEndApiResponse invoke(ApiRequest apiRequest, byte[] requestBody) {
    try {
        String responseBody = "<name>apiman</name>";
        ApiResponse apiResponse = new ApiResponse();
        apiResponse.getHeaders().put("Content-Type", "application/xml");
        apiResponse.getHeaders().put("Content-Length", String.valueOf(responseBody.getBytes("UTF-8").length));
        return new PolicyTestBackEndApiResponse(apiResponse, responseBody);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
}
Also used : PolicyTestBackEndApiResponse(io.apiman.test.policies.PolicyTestBackEndApiResponse) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ApiResponse(io.apiman.gateway.engine.beans.ApiResponse) PolicyTestBackEndApiResponse(io.apiman.test.policies.PolicyTestBackEndApiResponse)

Aggregations

ApiResponse (io.apiman.gateway.engine.beans.ApiResponse)21 IApimanBuffer (io.apiman.gateway.engine.io.IApimanBuffer)7 ApiRequest (io.apiman.gateway.engine.beans.ApiRequest)5 PolicyTestBackEndApiResponse (io.apiman.test.policies.PolicyTestBackEndApiResponse)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 AbstractStream (io.apiman.gateway.engine.io.AbstractStream)4 ISignalWriteStream (io.apiman.gateway.engine.io.ISignalWriteStream)4 Test (org.junit.Test)4 IPolicyContext (io.apiman.gateway.engine.policy.IPolicyContext)3 IOException (java.io.IOException)3 IApiRequestExecutor (io.apiman.gateway.engine.IApiRequestExecutor)2 IEngine (io.apiman.gateway.engine.IEngine)2 IEngineResult (io.apiman.gateway.engine.IEngineResult)2 IAsyncResultHandler (io.apiman.gateway.engine.async.IAsyncResultHandler)2 ComponentNotFoundException (io.apiman.gateway.engine.beans.exceptions.ComponentNotFoundException)2 IBufferFactoryComponent (io.apiman.gateway.engine.components.IBufferFactoryComponent)2 ICacheStoreComponent (io.apiman.gateway.engine.components.ICacheStoreComponent)2 ByteBuffer (io.apiman.gateway.engine.io.ByteBuffer)2 JsonpConfigBean (io.apiman.plugins.jsonp_policy.beans.JsonpConfigBean)2 IApiConnectionResponse (io.apiman.gateway.engine.IApiConnectionResponse)1