Skip to content

Commit

Permalink
Add HTTP PATCH method (drogonframework#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
itgenie98 authored Jun 14, 2020
1 parent 2457f9b commit 14b5ec0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/simple_example/DigestAuthFilter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ std::string method2String(HttpMethod m)
return "DELETE";
case Options:
return "OPTIONS";
case Patch:
return "PATCH";
default:
return "INVALID";
}
Expand Down
3 changes: 3 additions & 0 deletions examples/simple_example/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ int main()
case Head:
std::cout << " (Head) ";
break;
case Patch:
std::cout << " (PATCH) ";
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions lib/inc/drogon/HttpTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ enum HttpMethod
Put,
Delete,
Options,
Patch,
Invalid
};

Expand Down
4 changes: 4 additions & 0 deletions lib/src/ConfigLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ static void loadControllers(const Json::Value &controllers)
{
constraints.push_back(Delete);
}
else if (strMethod == "patch")
{
constraints.push_back(Patch);
}
}
}
if (!controller["filters"].isNull())
Expand Down
13 changes: 13 additions & 0 deletions lib/src/HttpRequestImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ const char *HttpRequestImpl::methodString() const
case Options:
result = "OPTIONS";
break;
case Patch:
result = "PATCH";
break;
default:
break;
}
Expand Down Expand Up @@ -576,6 +579,16 @@ bool HttpRequestImpl::setMethod(const char *start, const char *end)
method_ = Invalid;
}
break;
case 5:
if (m == "PATCH")
{
method_ = Patch;
}
else
{
method_ = Invalid;
}
break;
case 6:
if (m == "DELETE")
{
Expand Down

0 comments on commit 14b5ec0

Please sign in to comment.