Class DefaultGoApiResponse
java.lang.Object
com.thoughtworks.go.plugin.api.response.GoApiResponse
com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse
Default implementation of GoApiResponse
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionDefaultGoApiResponse(int responseCode) Constructs DefaultGoApiResponse with response code -
Method Summary
Modifier and TypeMethodDescriptionvoidaddResponseHeader(String name, String value) Adds new response header.static DefaultGoApiResponsebadRequest(String responseBody) Creates an instance DefaultGoApiResponse which represents bad request with response code 400static DefaultGoApiResponseCreates an instance DefaultGoApiResponse which represents error request with response code 500static DefaultGoApiResponseincompleteRequest(String responseBody) Creates an instance DefaultGoApiResponse which represents incomplete request with response code 412Provides json formatted response bodyintProvides response code for the request sentProvides response headers as key value pair for the response.voidsetResponseBody(String responseBody) Sets response bodystatic DefaultGoApiResponseCreates an instance DefaultGoApiResponse which represents success request with response code 200
-
Field Details
-
SUCCESS_RESPONSE_CODE
public static final int SUCCESS_RESPONSE_CODE- See Also:
-
REDIRECT_RESPONSE_CODE
public static final int REDIRECT_RESPONSE_CODE- See Also:
-
INTERNAL_ERROR
public static final int INTERNAL_ERROR- See Also:
-
VALIDATION_ERROR
public static final int VALIDATION_ERROR- See Also:
-
-
Constructor Details
-
DefaultGoApiResponse
public DefaultGoApiResponse(int responseCode) Constructs DefaultGoApiResponse with response code- Parameters:
responseCode- Response code for the response
-
-
Method Details
-
incompleteRequest
Creates an instance DefaultGoApiResponse which represents incomplete request with response code 412- Parameters:
responseBody- Response body- Returns:
- an instance of DefaultGoApiResponse
-
badRequest
Creates an instance DefaultGoApiResponse which represents bad request with response code 400- Parameters:
responseBody- Response body- Returns:
- an instance of DefaultGoApiResponse
-
error
Creates an instance DefaultGoApiResponse which represents error request with response code 500- Parameters:
responseBody- Response body- Returns:
- an instance of DefaultGoApiResponse
-
success
Creates an instance DefaultGoApiResponse which represents success request with response code 200- Parameters:
responseBody- Json formatted response body- Returns:
- an instance of DefaultGoApiResponse
-
addResponseHeader
Adds new response header. Replace existing header with same name- Parameters:
name- Name of the headervalue- Value of the header
-
setResponseBody
Sets response body- Parameters:
responseBody- Json formatted response body represented as string
-
responseCode
public int responseCode()Provides response code for the request sent- Specified by:
responseCodein classGoApiResponse- Returns:
-
responseHeaders
Provides response headers as key value pair for the response. Response headers can be used to send any meta information related to response- Specified by:
responseHeadersin classGoApiResponse- Returns:
- request headers as a Map
-
responseBody
Provides json formatted response body- Specified by:
responseBodyin classGoApiResponse- Returns:
- response body
-