Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit18deb49

Browse files
committed
Merge pull requestFirebaseExtended#40 from ed7coyne/master
Added remove() method.
2 parents4acc510 +ad17ca1 commit18deb49

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

‎Firebase.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ Firebase& Firebase::auth(const String& auth) {
2828
}
2929

3030
StringFirebase::get(const String& path) {
31-
returnsendRequest("GET", path);
31+
sendRequest("GET", path);
32+
returnreadBody();
3233
}
3334

3435
StringFirebase::push(const String& path,const String& value) {
35-
returnsendRequest("POST", path, value);
36+
sendRequest("POST", path, value);
37+
returnreadBody();
38+
}
39+
40+
voidFirebase::remove(const String& path) {
41+
sendRequest("DELETE", path);
3642
}
3743

3844
Firebase&Firebase::stream(const String& path) {
@@ -74,15 +80,20 @@ String Firebase::makeURL(const String& path) {
7480
return url;
7581
}
7682

77-
StringFirebase::sendRequest(constchar* method,const String& path,const String& value) {
78-
_error.reset();
83+
voidFirebase::sendRequest(constchar* method,const String& path,const String& value) {
7984
String url =makeURL(path);
8085
_http.begin(_host.c_str(), firebasePort, url.c_str(),true, firebaseFingerprint);
81-
int statusCode = _http.sendRequest(method, (uint8_t*)value.c_str(), value.length());
86+
int statusCode = _http.sendRequest(method, (uint8_t*)value.c_str(), value.length());
87+
_error.reset();
8288
if (statusCode <0) {
8389
_error.set(statusCode,
84-
String(method) +"" + url +":"
85-
+HTTPClient::errorToString(statusCode));
90+
String(method) +"" + url +":"
91+
+HTTPClient::errorToString(statusCode));
92+
}
93+
}
94+
95+
StringFirebase::readBody() {
96+
if (_error.code() !=0) {
8697
return"";
8798
}
8899
// no _http.end() because of connection reuse.

‎Firebase.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Firebase {
5252
}
5353
Stringget(const String& path);
5454
Stringpush(const String& path,const String& value);
55+
voidremove(const String& path);
5556
boolconnected();
5657
Firebase&stream(const String& path);
5758
boolavailable();
@@ -63,7 +64,9 @@ class Firebase {
6364
Eventread(String& event);
6465
private:
6566
StringmakeURL(const String& path);
66-
StringsendRequest(constchar* method,const String& path,const String& value ="");
67+
voidsendRequest(constchar* method,const String& path,const String& value ="");
68+
StringreadBody();
69+
6770
HTTPClient _http;
6871
String _host;
6972
String _auth;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp