Giter Site home page Giter Site logo

falcon's Introduction

falcon

Package Version Hex Docs

โš ๏ธ WARNING: This package has not been thoroughly tested yet, please report any bugs you run into. I will work on adding tests in the future but the version you are currently looking at with this warning was made in constrained time to use in a project

Installation

This package can be added to your Gleam project:

gleam add falcon

and its documentation can be found at https://hexdocs.pm/falcon.

Usage

This package has not been documented, have a look in the test folder for more examples.

import falcon.{type FalconResponse}
import falcon/core.{Json, Url}
import gleam/dynamic
import gleam/io
import gleeunit/should

pub type PartialProduct {
  PartialProduct(id: Int, title: String)
}

pub fn main() {
  let decoder =
    dynamic.decode2(
      PartialProduct,
      dynamic.field("id", dynamic.int),
      dynamic.field("title", dynamic.string),
    )

  let client =
    falcon.new(
      base_url: Url("https://dummyjson.com/"),
      headers: [],
      timeout: falcon.default_timeout,
    )

  client
  |> falcon.get("/products/1", expecting: Json(decoder), options: [])
  |> should.be_ok
  |> fn(res: FalconResponse(PartialProduct)) { res.body }
  |> io.debug
}


// Output: PartialProduct(1, "iPhone 9")

Why should I use this?

You don't need to, Hackney is probably enough for whatever you are doing but if you need a bit more configuration options or an axios-like interface, this is for you.

NOTE: part of the hackney bindings were taken from the official Gleam hackney bindings and modified

falcon's People

Contributors

aosasona avatar

Stargazers

Bami David avatar

Watchers

 avatar  avatar

falcon's Issues

Allow an instance to be created with base config

This would mean moving the current implementation into a new module like src/facquest/core.gleam

I have still not decided on this name because I want people to be able to use the unbound APIs directly but core.get(...) sounds odd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.