Giter Site home page Giter Site logo

nap's Introduction

Nap

Disclaimer

Nap is in Beta, and not ready to be used on production projects yet.

Build/Test Status

Branch Status Coverage
Master Master Build status Coverage Status
Develop Develop Build status Coverage Status

Summary

Nap is a short and sweet REST client. It was made with the purpose of streamlining REST requests as much as possible.

Plugins and Extensions

Short

Nap is short.

var nap = new NapClient("http://example.com/");
var dogs = await nap.Get("/dogs").ExecuteAsync<Dogs>();
var cats = await nap.Get("http://otherexample.com/cats").ExecuteAsync<Cats>();

Or, even shorter!

var dogs = NapClient.Lets.Get("http://example.com/dogs").ExecuteAsync<Dogs>()

Sweet

Nap is sweet.

var ingredients = new { Flour = 10, Eggs = 2, CakeMix = 1 };
var cake = NapClient.Lets.Post("http://example.com/bake-cake")
                         .IncludeQueryParameter("temp", "425F")
                         .IncludeHeader("sugar", "100g")
                         .IncludeBody(ingredients)
                         .Execute<Cake>();

Configuration

Nap removes the need to configure stuff over and over again if you don't want to, or the need to create a client if you don't want one. Nap follows a cascading configuration pattern: NapClient() > Fluent.

In this example:

var nap = new NapClient();
nap.Config.QueryParameters["temp"] = "300F";
var cake = nap.Get("http://example.com/cake")
              .IncludeHeader("sugar", "10g")
              .Execute<Cake>();

The end result would perform an HTTP GET Request to http://example.com/cake, using a query parameter of "temp=300F" (Nap() configuration level) and a Header of "sugar: 10g" (Fluent level). This allows for a high degree of customization on a per-request or per-scope basis.

Powerful

Most of all, Nap is aimed at bringing the full power of the RESTful requests to your projects. Although few methods are exposed at the INapRequest level, the INapRequest.Advanced property quickly allows access to many more features:

var cake = NapClient.Lets.Get("http://example.com/cake")
                   .Advanced
                   .Proxy("http://localhost:8888")
                   .Authentication.Basic("[email protected]", "Password")
                   .UseSSL()
                   .Execute<Cake>()

Metadata properties are supported!

class Cake
{
  public bool Tasty { get; set; }
  public string Type { get; set; }
  public int StatusCode { get; set; }
}

var cake = NapClient.Lets.Get("http://example.com/cake")
                         .FillMetadata()
                         .Execute<Cake>()

In the above example, if the URL cake has no property called "Status Code", it would be populated by the FillMetadata() flag, and result in the status code of the request.

Deserialization is performed by default through Json.Net and XmlSerializer. Additional formatters for deserialization can be implemented by inheriting from the INapFormatter interface.

nap's People

Contributors

asmorger avatar jrwdexter avatar

Watchers

 avatar  avatar  avatar

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.