Update README with instructions for use
This commit is contained in:
parent
3e71e27e78
commit
061f029bf7
1 changed files with 20 additions and 0 deletions
20
README.md
20
README.md
|
@ -16,3 +16,23 @@ gleam add finch_gleam
|
||||||
```
|
```
|
||||||
|
|
||||||
and its documentation can be found at <https://hexdocs.pm/finch_gleam>.
|
and its documentation can be found at <https://hexdocs.pm/finch_gleam>.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```gleam
|
||||||
|
import gleam/uri
|
||||||
|
import gleam/http
|
||||||
|
import gleam/http/request
|
||||||
|
import gleam/erlang/atom
|
||||||
|
import finch
|
||||||
|
|
||||||
|
assert Ok(url) = uri.parse("https://example.com/")
|
||||||
|
assert Ok(req) = request.from_uri(url)
|
||||||
|
let req = request.Request(..req, method: http.Post, body: "foo bar")
|
||||||
|
|
||||||
|
// Build Finch request from gleam/http request
|
||||||
|
let finch_req = finch.build(req, [])
|
||||||
|
|
||||||
|
// Run request with Finch, using Finch.Server, returns gleam/http response
|
||||||
|
assert Ok(resp) = finch.request(finch_req, atom.create_from_string("Elixir.Finch.Server"))
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue