rest-client

A REST client for Haxe.
https://github.com/tbrosman/haxe-rest-client

To install, run:

haxelib install rest-client 0.3.0 

See using Haxelib in Haxelib documentation for more information.

README.md

Haxe rest-client

A REST-ish wrapper around Haxe's built-in HTTP functionality

Motivation

This library grew out of a logging client I created for another Haxe project. I could not find an existing haxelib that handled REST client functionality (most likely because Haxe's HTTP library is missing so much) so I threw together my own.

I am aware of haxe.web.Dispatch but find it cumbersome for free-form REST calls (a good discussion about this can be found here).

Features

Both synchronous and asynchronous requests are supported (with some restrictions depending on platform, see below).

The interface is designed to be clean and readable as well as symmetric between sync and async requests:

    var result = RestClient.get(
        "http://localhost:8000/item/1",
        ["testParam" => "asdf"]);
    trace(result;

    var result = RestClient.getAsync(
        "http://localhost:8000/item/1",
        function(result)
        {
            trace(result);
        },
        ["testParam" => "asdf"]);

Platforms

This has been tested on Neko, Flash, and CPP (on Android) targets. Flash is the only platform (that I know of) that doesn't support some form of synchronous requests/sockets. For all other platforms Http.customRequest is used.

If you find any issues using this library with your platform of choice, feel free to open an issue/make a pull request.

Limitations

  • Currently GET, POST, PUT and DELETE are supported. X-HTTP-Method-Override header is used to implement PUT and DELETE for Flash. HTTP method override can also be manually enabled to work around deep inspection firewalls.

Future

  • SSL support
  • Unit tests for more platforms
Contributors
tbrosman
Version
0.3.0
Published
6 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub