Skip to content

Commit

Permalink
Add OPTIONS support to HTTP client (#128)
Browse files Browse the repository at this point in the history
Signed-off-by: Johnneylee Jack Rollins <Johnneylee.Rollins@gmail.com>
  • Loading branch information
Spaceghost authored and mikusp committed Feb 19, 2018
1 parent 5574ff0 commit 4082dea
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions stdlib/Std/src/HTTP.luna
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ class HttpMethod:
PUT
PATCH
DELETE
OPTIONS

def toText: case self of
POST: "POST"
GET: "GET"
PUT: "PUT"
PATCH: "PATCH"
DELETE: "DELETE"
POST: "POST"
GET: "GET"
PUT: "PUT"
PATCH: "PATCH"
DELETE: "DELETE"
OPTIONS: "OPTIONS"

## Helper class for passing parameters in the body of an Http request
class HttpSimpleBody:
Expand Down Expand Up @@ -208,6 +210,10 @@ class Http:
def delete uri:
defaultHttpRequest uri . setMethod DELETE

## Create an Http OPTIONS request for a given url.
def options uri:
defaultHttpRequest uri . setMethod OPTIONS

## A helper method that immediately gets a binary blob from a given url.
## There is no need to call `perform` here, as it returns a `Binary` response.
def getBinary uri:
Expand Down

0 comments on commit 4082dea

Please sign in to comment.