public class HttpOperator extends Object
Tuple resource = http("https://your.resource.server/resource.csv")
.header("Authorization", "Bearer: mytoken")
.post(body)
// this part is specific to a JSON body response
.asTuple();
Modifier and Type | Field and Description |
---|---|
protected RuntimeContext |
runtimeContext
The caller punchlet runtime context.
|
protected String |
url
The remote or local resource url.
|
Constructor and Description |
---|
HttpOperator(RuntimeContext r,
String url)
Ctor.
|
Modifier and Type | Method and Description |
---|---|
String |
asString()
Get response as plain string text
|
Tuple |
asTuple()
Get response as Tuple
|
HttpOperator |
data(String body)
Http POST and PUT data as plain string
|
HttpOperator |
data(Tuple body)
Http POST and PUT data as plain string
|
HttpOperator |
get()
Set request as GET.
|
HttpOperator |
header(String key,
String value)
Add an http header
|
HttpOperator |
method(String method)
Set request method
|
HttpOperator |
post()
Set request as POST
|
HttpOperator |
put()
Set request as PUT
|
HttpOperator |
timeout(int timeout) |
protected final String url
protected final RuntimeContext runtimeContext
public HttpOperator(RuntimeContext r, String url)
r
- the punchlet runtime context.url
- an http url.public HttpOperator method(String method)
public HttpOperator post()
public HttpOperator put()
public HttpOperator get()
public HttpOperator timeout(int timeout)
public HttpOperator header(String key, String value)
key
- value
- public HttpOperator data(String body)
body
- as Stringpublic HttpOperator data(Tuple body)
body
- as tuplepublic String asString()
public Tuple asTuple()
Copyright © 2022. All rights reserved.