GogsHttp (gogs v0.9.0)

Documentation for the HTTP "verb" functions. Should be self-explanatory. Each function documented & typespecd.
If anything is unclear, please open an issue: github.com/dwyl/gogs/issues

Link to this section Summary

Functions

delete/1 accepts a single argument url; the url for the repository to be deleted.

get/1 accepts one argument: url the REST API endpoint. Makes an HTTP GET request to the specified url. Auth Headers and Content-Type are implicit. returns {:ok, map}

get_raw/1 as it's name suggests gets the raw data (expects the reponse to be plaintext not JSON) accepts one argument: url the REST API endpoint. Makes an HTTP GET request to the specified url. Auth Headers and Content-Type are implicit. returns {:ok, map}

parse_body_response/1 parses the response returned by the Gogs Server so your app can use the resulting JSON.

post/2 accepts two arguments: url and params. Makes an HTTP POST request to the specified url passing in the params as the request body. Auth Headers and Content-Type are implicit.

Link to this section Functions

@spec delete(String.t()) :: {:ok, map()} | {:error, any()}

delete/1 accepts a single argument url; the url for the repository to be deleted.

@spec get(String.t()) :: {:ok, map()} | {:error, any()}

get/1 accepts one argument: url the REST API endpoint. Makes an HTTP GET request to the specified url. Auth Headers and Content-Type are implicit. returns {:ok, map}

@spec get_raw(String.t()) :: {:ok, map()} | {:error, any()}

get_raw/1 as it's name suggests gets the raw data (expects the reponse to be plaintext not JSON) accepts one argument: url the REST API endpoint. Makes an HTTP GET request to the specified url. Auth Headers and Content-Type are implicit. returns {:ok, map}

Link to this function

inject_poison()

inject_poison/0 injects a TestDouble of HTTPoison in Test. see: https://github.com/dwyl/elixir-auth-google/issues/35

Link to this function

parse_body_response(arg)

@spec parse_body_response({atom(), String.t()} | {:error, any()}) ::
  {:ok, map()} | {:error, any()}

parse_body_response/1 parses the response returned by the Gogs Server so your app can use the resulting JSON.

Link to this function

post(url, params \\ %{})

@spec post(String.t(), map()) :: {:ok, map()} | {:error, any()}

post/2 accepts two arguments: url and params. Makes an HTTP POST request to the specified url passing in the params as the request body. Auth Headers and Content-Type are implicit.