All Projects → epicallan → Hreq

epicallan / Hreq

Licence: mit
A type dependent highlevel HTTP client library inspired by servant-client.

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Hreq

Oh My Request
🔮 simple request library by java8
Stars: ✭ 44 (-16.98%)
Mutual labels:  network, http-client
Curlsharp
CurlSharp - .Net binding and object-oriented wrapper for libcurl.
Stars: ✭ 153 (+188.68%)
Mutual labels:  network, http-client
Qtnetworkng
QtNetwork Next Generation. A coroutine based network framework for Qt/C++, with more simpler API than boost::asio.
Stars: ✭ 125 (+135.85%)
Mutual labels:  network, http-client
Grab
Web Scraping Framework
Stars: ✭ 2,147 (+3950.94%)
Mutual labels:  network, http-client
Fast Android Networking
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀
Stars: ✭ 5,346 (+9986.79%)
Mutual labels:  network, http-client
Httplib2
Small, fast HTTP client library for Python. Features persistent connections, cache, and Google App Engine support. Originally written by Joe Gregorio, now supported by community.
Stars: ✭ 402 (+658.49%)
Mutual labels:  network, http-client
Libhv
🔥 比libevent、libuv更易用的国产网络库。A c/c++ network library for developing TCP/UDP/SSL/HTTP/WebSocket client/server.
Stars: ✭ 3,355 (+6230.19%)
Mutual labels:  network, http-client
Sylar
C++高性能分布式服务器框架,webserver,websocket server,自定义tcp_server(包含日志模块,配置模块,线程模块,协程模块,协程调度模块,io协程调度模块,hook模块,socket模块,bytearray序列化,http模块,TcpServer模块,Websocket模块,Https模块等, Smtp邮件模块, MySQL, SQLite3, ORM,Redis,Zookeeper)
Stars: ✭ 895 (+1588.68%)
Mutual labels:  network, http-client
Easygo
基于Kotlin、OkHttp的声明式网络框架,像写HTML界面一样写网络调用代码
Stars: ✭ 40 (-24.53%)
Mutual labels:  network, http-client
Eventd
A simple daemon to track remote or local events and do actions the user wants to
Stars: ✭ 43 (-18.87%)
Mutual labels:  network
Pyrwr
Python Implementation for Random Walk with Restart (RWR)
Stars: ✭ 48 (-9.43%)
Mutual labels:  network
Vue Network
Render a Vue component to indicate network status.
Stars: ✭ 42 (-20.75%)
Mutual labels:  network
Aplay
A Better(Maybe) iOS Audio Stream、Cache、Play Framework
Stars: ✭ 44 (-16.98%)
Mutual labels:  network
Pnet
High level Java network library
Stars: ✭ 49 (-7.55%)
Mutual labels:  network
Gasmodels.jl
A Julia/JuMP Package for Gas Network Optimization
Stars: ✭ 43 (-18.87%)
Mutual labels:  network
Tech1 Benchmarks
Java JMH Benchmarks repository. No Longer Supported.
Stars: ✭ 50 (-5.66%)
Mutual labels:  http-client
G6
♾ A Graph Visualization Framework in JavaScript
Stars: ✭ 8,490 (+15918.87%)
Mutual labels:  network
Dknetworking
基于 AFNetworking + YYCache 的二次封装,支持缓存策略的网络请求框架
Stars: ✭ 41 (-22.64%)
Mutual labels:  network
Pythem
pentest framework
Stars: ✭ 1,060 (+1900%)
Mutual labels:  network
V2ray Core
A platform for building proxies to bypass network restrictions.
Stars: ✭ 13,438 (+25254.72%)
Mutual labels:  network

Hreq

Hackage MIT license Build status

Intro

Hreq is a high-level easy to use type-driven HTTP client library inspired by Servant-Client. Hreq provides an alternative approach to type-safe construction and interpretation of API endpoints for Http client requests.

The Hreq github repository is a mono-repo composed of the following:

  • hreq-core implementing core functionality.

  • hreq-client an HTTP client using hreq-core functionality

  • hreq-conduit an HTTP client with streaming support via conduit.

Checkout accompanying blog post and minimal tutorial for more details

Motivation

Hreq was motivated by the simplicity and ease of use of req and the type driven elegance of servant-client. I envisioned Hreq as the best possible compromise of both worlds.

Some of the Key Points

  • A default HTTP client manager is set up within the library such that one doesn't have to think about manager configuration.

  • Hreq provides type synonyms for common API type combinators, therefore, reducing on API types verbosity.

  • In Hreq, API types are used directly within API functions via Type Application while in servant-client API types create new API functions for creating API requests.

  • In Hreq, API Request component arguments are provided to the API function through a Heterogeneous list.

  • Hreq supports the concept of Retry policy, whereby an http request is retried automatically on network connection failure based on a set Retry policy.

Usage Example

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DataKinds  #-}

module Main where

import Data.Aeson (FromJSON, ToJSON)
import GHC.Generics (Generic)
import Hreq.Client

data User = User
  { name :: String
  , age  :: Int
  } deriving (Show, Generic, FromJSON, ToJSON)

main' :: IO ()
main' = do
  res <- runHreq baseUrl $ do
    -- | Makes Post request with newUser as a request body
    createdUser <- createUser newUser
    -- | Makes Get Request with "allan" as a URL fragment
    myUser      <- getUserByName "allan"
    -- | Makes a Get Request returning a list of Users
    allUsers    <- hreq @(GetJson [User]) Empty
    return (createdUser, myUser, allUsers)
  print res
  where
    baseUrl :: BaseUrl
    baseUrl = HttpDomain "example.com"

    newUser :: User
    newUser = User "Allan" 29

createUser :: RunClient m => User -> m User
createUser user = hreq @(JsonBody User :> PostJson User) (user :. Empty)

getUserByName :: RunClient m => String -> m User
getUserByName userName = hreq @(Capture String :> GetJson User) (userName :. Empty)

Attribution

Hreq is heavily inspired by servant-client and ideas from Serv.

Documentation

This README is tested by markdown-unlit to make sure the code builds. To keep that happy, we do need a main in this file, so ignore the following :)

main :: IO ()
main = pure ()
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].