Giter Site home page Giter Site logo

swish's Introduction

Swish

Overview

Swish is a Modern C++ 17 HTTP client library for Humans

Swish is for the most parts, A simple libcurl wrapper which provides, data structures and type safe OOP abstractions to make operating with libcurl much easier and pain free as compared to error-prone manual manipulation of net. sockets.

Features

  • Provides implementations for GET, POST (Multipart and Form Fields), DELETE, HEAD, TRACE etc.
  • Fast file download
  • Simple and expressive API (type safe OOP)
  • Byte type customization
  • Almost zero cost abstraction
  • Supports local file://location
  • Custom data structures for ease of use
  • Proxy and OAuth support

Installation

  • Install libcurl (7.60.0 or higher)
  • clone this repo
  • build and install using cmake e.g. For linux users
user@pc:~$ cmake .
user@pc:~$ sudo make install
  • or copy the swish directory to your project's local or global include path

Quick Start

/**
 * @file: example.cc
 *
 */
#include <swish/swish.h>

using namespace swish;

int main() {
  // create a new HTTP client
  auto client = Client();

  // Perform request
  auto [response, status] = client.Get("https://github.com");

  // Check if any errors occured
  if (IsOK(status)) {
    // convert body buffer to std::basic_string<char> aka std::string
    std::cout << response.body.ToString() << "\n";

  } else {
    // Interpret status code to english
    std::cerr << "The following Error occured: " << InterpretStatusCode(status)
              << "\n";
  }

  return EXIT_SUCCESS;
}

Building

Swish depends on libcurl, ensure you have an active installation. Compile with the -lcurl postfix flag e.g in clang :

user@pc:~$ clang++ -std=c++17 example.cc -o example.o -lcurl
user@pc:~$ clang++ -std=c++17 example.cc -o example.o -lcurl
user@pc:~$ ./example.o

swish's People

Contributors

lamarrr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

swish's Issues

How send MultipartFormData http post request?

How I can upload file to server use swish?

auto client = Client();

auto multipartFormData = MultipartFormData(&client);
multipartFormData = std::move(multipartFormData.PushField("imageid", "8948"));
multipartFormData = std::move(multipartFormData.PushField("file_type", "img"));
multipartFormData = std::move(multipartFormData.AttachFile("file", "test1.png"));

auto [response, status] = client.Post("http://any.com/uploadImage", &multipartFormData);

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.