com.github.restdriver.serverdriver
Class RestServerDriver

java.lang.Object
  extended by com.github.restdriver.serverdriver.RestServerDriver

public final class RestServerDriver
extends Object

Provides static methods for performing HTTP requests against a resource.

Author:
mjg

Method Summary
static RequestBody body(String content, String contentType)
          Make a RequestBody for PUT or POST.
static Response delete(Object url, Header... headers)
          Send an HTTP delete.
static Response deleteOf(Object url, Header... headers)
          Synonym for delete(Object, Header...).
static Response deleting(Object url, Header... headers)
          Synonym for delete(Object, Header...).
static Response doDeleteOf(Object url, Header... headers)
          Synonym for delete(Object, Header...).
static Response doGetOf(Object url, Header... headers)
          Synonym for get(Object, Header...).
static Response doPostOf(Object url, RequestBody body, Header... headers)
          Synonym for post(Object, RequestBody, Header...).
static Response doPutOf(Object url, RequestBody body, Header... headers)
          Synonym for put(Object, RequestBody, Header...).
static Response get(Object url, Header... headers)
          Perform an HTTP GET on a resource.
static Response getOf(Object url, Header... headers)
          Synonym for get(Object, Header...).
static Response getting(Object url, Header... headers)
          Synonym for get(Object, Header...).
static Header header(String name, String value)
          Make a Header.
static Response post(Object url, RequestBody body, Header... headers)
          Perform an HTTP POST to the given URL.
static Response posting(Object url, RequestBody body, Header... headers)
          Synonym for post(Object, RequestBody, Header...).
static Response postOf(Object url, RequestBody body, Header... headers)
          Synonym for post(Object, RequestBody, Header...).
static Response put(Object url, RequestBody body, Header... headers)
          Perform an HTTP PUT to the given URL.
static Response putOf(Object url, RequestBody body, Header... headers)
          Synonym for put(Object, RequestBody, Header...).
static Response putting(Object url, RequestBody body, Header... headers)
          Synonym for put(Object, RequestBody, Header...).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

header

public static Header header(String name,
                            String value)
Make a Header.

Parameters:
name - The name for the header
value - The value for the header
Returns:
The new header instance

body

public static RequestBody body(String content,
                               String contentType)
Make a RequestBody for PUT or POST.

Parameters:
content - Request body content as String
contentType - content-type eg text/plain
Returns:
The new request body instance

get

public static Response get(Object url,
                           Header... headers)
Perform an HTTP GET on a resource.

Parameters:
url - The URL of a resource. Accepts any Object and calls .toString() on it.
headers - Optional HTTP headers to put on the request.
Returns:
A Response encapsulating the server's reply.

getOf

public static Response getOf(Object url,
                             Header... headers)
Synonym for get(Object, Header...).

Parameters:
url - The URL of a resource. Accepts any Object and calls .toString() on it.
headers - Optional HTTP headers to put on the request.
Returns:
A Response encapsulating the server's reply.

doGetOf

public static Response doGetOf(Object url,
                               Header... headers)
Synonym for get(Object, Header...).

Parameters:
url - The URL of a resource. Accepts any Object and calls .toString() on it.
headers - Optional HTTP headers to put on the request.
Returns:
A Response encapsulating the server's reply.

getting

public static Response getting(Object url,
                               Header... headers)
Synonym for get(Object, Header...).

Parameters:
url - The URL of a resource. Accepts any Object and calls .toString() on it.
headers - Optional HTTP headers to put on the request.
Returns:
A Response encapsulating the server's reply.

post

public static Response post(Object url,
                            RequestBody body,
                            Header... headers)
Perform an HTTP POST to the given URL.

Parameters:
url - The URL. Any object may be passed, we will call .toString() on it.
body - The body of the post, as text/plain.
headers - Any HTTP headers.
Returns:
Response encapsulating the server's reply

postOf

public static Response postOf(Object url,
                              RequestBody body,
                              Header... headers)
Synonym for post(Object, RequestBody, Header...).

Parameters:
url - The URL. Any object may be passed, we will call .toString() on it.
body - The body of the post, as text/plain.
headers - Any HTTP headers.
Returns:
Response encapsulating the server's reply

doPostOf

public static Response doPostOf(Object url,
                                RequestBody body,
                                Header... headers)
Synonym for post(Object, RequestBody, Header...).

Parameters:
url - The URL. Any object may be passed, we will call .toString() on it.
body - The body of the post, as text/plain.
headers - Any HTTP headers.
Returns:
Response encapsulating the server's reply

posting

public static Response posting(Object url,
                               RequestBody body,
                               Header... headers)
Synonym for post(Object, RequestBody, Header...).

Parameters:
url - The URL. Any object may be passed, we will call .toString() on it.
body - The body of the post, as text/plain.
headers - Any HTTP headers.
Returns:
Response encapsulating the server's reply

put

public static Response put(Object url,
                           RequestBody body,
                           Header... headers)
Perform an HTTP PUT to the given URL.

Parameters:
url - The URL. Any object may be passed, we will call .toString() on it.
body - The body of the post, as text/plain.
headers - Any HTTP headers.
Returns:
Response encapsulating the server's reply

putOf

public static Response putOf(Object url,
                             RequestBody body,
                             Header... headers)
Synonym for put(Object, RequestBody, Header...).

Parameters:
url - The URL. Any object may be passed, we will call .toString() on it.
body - The body of the post, as text/plain.
headers - Any HTTP headers.
Returns:
Response encapsulating the server's reply

doPutOf

public static Response doPutOf(Object url,
                               RequestBody body,
                               Header... headers)
Synonym for put(Object, RequestBody, Header...).

Parameters:
url - The URL. Any object may be passed, we will call .toString() on it.
body - The body of the post, as text/plain.
headers - Any HTTP headers.
Returns:
Response encapsulating the server's reply

putting

public static Response putting(Object url,
                               RequestBody body,
                               Header... headers)
Synonym for put(Object, RequestBody, Header...).

Parameters:
url - The URL. Any object may be passed, we will call .toString() on it.
body - The body of the post, as text/plain.
headers - Any HTTP headers.
Returns:
Response encapsulating the server's reply

delete

public static Response delete(Object url,
                              Header... headers)
Send an HTTP delete.

Parameters:
url - The resource to delete
headers - Any http headers
Returns:
Response encapsulating the server's reply

deleteOf

public static Response deleteOf(Object url,
                                Header... headers)
Synonym for delete(Object, Header...).

Parameters:
url - The resource to delete
headers - Any http headers
Returns:
Response encapsulating the server's reply

doDeleteOf

public static Response doDeleteOf(Object url,
                                  Header... headers)
Synonym for delete(Object, Header...).

Parameters:
url - The resource to delete
headers - Any http headers
Returns:
Response encapsulating the server's reply

deleting

public static Response deleting(Object url,
                                Header... headers)
Synonym for delete(Object, Header...).

Parameters:
url - The resource to delete
headers - Any http headers
Returns:
Response encapsulating the server's reply


Copyright © 2011. All Rights Reserved.