-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from vinscom/develop
dev-to-master
- Loading branch information
Showing
8 changed files
with
485 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package in.erail.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
import com.google.common.io.BaseEncoding; | ||
import io.vertx.core.http.HttpMethod; | ||
import java.util.Map; | ||
|
||
/** | ||
* | ||
* @author vinay | ||
*/ | ||
@JsonInclude(Include.NON_NULL) | ||
public class ReqestEvent { | ||
|
||
private String mResource; | ||
private String mPath; | ||
private HttpMethod mHttpMethod; | ||
private Map<String, String> mHeaders; | ||
private Map<String, String[]> mMultiValueHeaders; | ||
private Map<String, String> mQueryStringParameters; | ||
private Map<String, String[]> mMultiValueQueryStringParameters; | ||
private Map<String, String> mPathParameters; | ||
private Map<String, String> mStageVariables; | ||
private Map mRequestContext; | ||
private byte[] mBody = new byte[0]; | ||
private boolean mIsBase64Encoded = false; | ||
|
||
public String getResource() { | ||
return mResource; | ||
} | ||
|
||
public void setResource(String pResource) { | ||
this.mResource = pResource; | ||
} | ||
|
||
public String getPath() { | ||
return mPath; | ||
} | ||
|
||
public void setPath(String pPath) { | ||
this.mPath = pPath; | ||
} | ||
|
||
public HttpMethod getHttpMethod() { | ||
return mHttpMethod; | ||
} | ||
|
||
public void setHttpMethod(HttpMethod pHttpMethod) { | ||
this.mHttpMethod = pHttpMethod; | ||
} | ||
|
||
public Map<String, String> getHeaders() { | ||
return mHeaders; | ||
} | ||
|
||
public void setHeaders(Map<String, String> pHeaders) { | ||
this.mHeaders = pHeaders; | ||
} | ||
|
||
public Map<String, String[]> getMultiValueHeaders() { | ||
return mMultiValueHeaders; | ||
} | ||
|
||
public void setMultiValueHeaders(Map<String, String[]> pMultiValueHeaders) { | ||
this.mMultiValueHeaders = pMultiValueHeaders; | ||
} | ||
|
||
public Map<String, String> getQueryStringParameters() { | ||
return mQueryStringParameters; | ||
} | ||
|
||
public void setQueryStringParameters(Map<String, String> pQueryStringParameters) { | ||
this.mQueryStringParameters = pQueryStringParameters; | ||
} | ||
|
||
public Map<String, String[]> getMultiValueQueryStringParameters() { | ||
return mMultiValueQueryStringParameters; | ||
} | ||
|
||
public void setMultiValueQueryStringParameters(Map<String, String[]> pMultiValueQueryStringParameters) { | ||
this.mMultiValueQueryStringParameters = pMultiValueQueryStringParameters; | ||
} | ||
|
||
public Map<String, String> getPathParameters() { | ||
return mPathParameters; | ||
} | ||
|
||
public void setPathParameters(Map<String, String> pPathParameters) { | ||
this.mPathParameters = pPathParameters; | ||
} | ||
|
||
public Map<String, String> getStageVariables() { | ||
return mStageVariables; | ||
} | ||
|
||
public void setStageVariables(Map<String, String> pStageVariables) { | ||
this.mStageVariables = pStageVariables; | ||
} | ||
|
||
public Map getRequestContext() { | ||
return mRequestContext; | ||
} | ||
|
||
public void setRequestContext(Map pRequestContext) { | ||
this.mRequestContext = pRequestContext; | ||
} | ||
|
||
public boolean isIsBase64Encoded() { | ||
return mIsBase64Encoded; | ||
} | ||
|
||
public void setIsBase64Encoded(boolean pIsBase64Encoded) { | ||
this.mIsBase64Encoded = pIsBase64Encoded; | ||
} | ||
|
||
public byte[] getBody() { | ||
return mBody; | ||
} | ||
|
||
public void setBody(byte[] pBody) { | ||
this.mBody = pBody; | ||
} | ||
|
||
public String bodyAsString(){ | ||
if(isIsBase64Encoded()){ | ||
return new String(BaseEncoding.base64().decode(new String(getBody()))); | ||
} | ||
return new String(getBody()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package in.erail.model; | ||
|
||
import com.google.common.net.HttpHeaders; | ||
import com.google.common.net.MediaType; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* | ||
* @author vinay | ||
*/ | ||
public class ResponseEvent { | ||
|
||
private Map<String, String>[] mCookies; | ||
private boolean mIsBase64Encoded = true; | ||
private int mStatusCode = 200; | ||
private Map<String, String> mHeaders; | ||
private Map<String, String[]> mMultiValueHeaders; | ||
private byte[] mBody = new byte[0]; | ||
|
||
public boolean isIsBase64Encoded() { | ||
return mIsBase64Encoded; | ||
} | ||
|
||
public void setIsBase64Encoded(boolean pIsBase64Encoded) { | ||
this.mIsBase64Encoded = pIsBase64Encoded; | ||
} | ||
|
||
public int getStatusCode() { | ||
return mStatusCode; | ||
} | ||
|
||
public void setStatusCode(int pStatusCode) { | ||
this.mStatusCode = pStatusCode; | ||
} | ||
|
||
public Map<String, String> getHeaders() { | ||
if (mHeaders == null) { | ||
mHeaders = new HashMap<>(); | ||
} | ||
return mHeaders; | ||
} | ||
|
||
public void setHeaders(Map<String, String> pHeaders) { | ||
this.mHeaders = pHeaders; | ||
} | ||
|
||
public byte[] getBody() { | ||
return mBody; | ||
} | ||
|
||
public void setBody(byte[] pBody) { | ||
this.mBody = pBody; | ||
} | ||
|
||
public Map<String, String[]> getMultiValueHeaders() { | ||
if (mMultiValueHeaders == null) { | ||
mMultiValueHeaders = new HashMap<>(); | ||
} | ||
return mMultiValueHeaders; | ||
} | ||
|
||
public void setMultiValueHeaders(Map<String, String[]> pMultiValueHeaders) { | ||
this.mMultiValueHeaders = pMultiValueHeaders; | ||
} | ||
|
||
public Map<String, String>[] getCookies() { | ||
return mCookies; | ||
} | ||
|
||
public void setCookies(Map<String, String>[] pCookies) { | ||
this.mCookies = pCookies; | ||
} | ||
|
||
public void addHeader(String pHeaderName, String pMediaType) { | ||
getHeaders().put(HttpHeaders.CONTENT_TYPE, pMediaType); | ||
} | ||
|
||
public void addHeader(String pHeaderName, MediaType pMediaType) { | ||
getHeaders().put(HttpHeaders.CONTENT_TYPE, pMediaType.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.