Package me.geso.mech2
Class Mech2WithBase
java.lang.Object
me.geso.mech2.Mech2WithBase
Mech2 object with base URI.
This class is useful when
- to write Restful HTTP API client.
- testing with embedded jetty
- Author:
- tokuhirom
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDisable redirect handling.Create new GET request.Get base URICreate new GET request usingString.format(String, Object...).getMech2()Get a mech2 instance.Create new POST request.Create new POST request contains JSON.postMultipart(String path) Create multi-part POST request(Charset is UTF-8).postMultipart(String path, Charset charset) Create new multi-part POST request.
-
Constructor Details
-
Mech2WithBase
-
-
Method Details
-
getMech2
Get a mech2 instance.- Returns:
- mech2 instance
-
getBaseURI
Get base URI- Returns:
- base URI object
-
get
Create new GET request.- Parameters:
path- request path- Returns:
- Generated request object.
- Throws:
URISyntaxException
-
getf
Create new GET request usingString.format(String, Object...).It's same as
. But readable.mech.get(String.format("/member/%s", member.getId())- Parameters:
pathFormat- path formatargs- parameters.- Returns:
- request object
- Throws:
URISyntaxException
-
disableRedirectHandling
Disable redirect handling.- Returns:
- fluent
-
post
Create new POST request.- Parameters:
path- path- Returns:
- request object
- Throws:
URISyntaxException
-
postJSON
public Mech2Request postJSON(String path, Object data) throws URISyntaxException, com.fasterxml.jackson.core.JsonProcessingException Create new POST request contains JSON.- Parameters:
path- path to requestdata- source of JSON. It'll serialize by jackson.- Returns:
- request object
- Throws:
URISyntaxExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
postMultipart
Create multi-part POST request(Charset is UTF-8).- Parameters:
path- path to request- Returns:
- request object
-
postMultipart
Create new multi-part POST request.- Parameters:
path- path to requestcharset- charset- Returns:
- request object
-