-
Notifications
You must be signed in to change notification settings - Fork 134
/
RestClient.h
56 lines (47 loc) · 1.4 KB
/
RestClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <Arduino.h>
#include <SPI.h>
#include <Ethernet.h>
class RestClient {
public:
RestClient(const char* host);
RestClient(const char* _host, int _port);
//Client Setup
bool dhcp();
int begin(byte*);
//Generic HTTP Request
int request(const char* method, const char* path,
const char* body, String* response);
// Set a Request Header
void setHeader(const char*);
// Set Content-Type Header
void setContentType(const char*);
// GET path
int get(const char*);
// GET path and response
int get(const char*, String*);
// POST path and body
int post(const char* path, const char* body);
// POST path and body and response
int post(const char* path, const char* body, String*);
// PUT path and body
int put(const char* path, const char* body);
// PUT path and body and response
int put(const char* path, const char* body, String*);
// DELETE path
int del(const char*);
// DELETE path and body
int del(const char*, const char*);
// DELETE path and response
int del(const char*, String*);
// DELETE path and body and response
int del(const char*, const char*, String*);
private:
EthernetClient client;
int readResponse(String*);
void write(const char*);
const char* host;
int port;
int num_headers;
const char* headers[10];
const char* contentType;
};