Coder Social home page Coder Social logo

whyll's Introduction

WHyLL

True object-oriented, declarative, DTO-free HTTP library. Make requests and responses using immutable objects.

Currently under development, without an alpha release.

HTTP is simple, so is this library.

You send a message to the server, and get a message back. The message, sent and received, is text and always in this shape:

First Line // Saying what you want (request) or what you got back (response)
Header * n // N Headers which have a name and a value, controls things

Body       //Can contain anything from Text to Downloads

This is how the library is designed. There is a message, which you can refine by first line, headers, and a body. Then, you render the message, using one of the available renderings. Most likely you render it to a response message, and then you render the response message to what you need, for example an XML document.

Setup a request

This is how you setup a request message:

var request = new Get(new Uri("http://www.enhanced-calm.com"));

Then, you can refine the headers:

var request = 
	new Get(new Uri("http://www.enhanced-calm.com/newest-postings"))
		.Refine(new Header("Content-Type", "application/json"))

And the body:

var request = 
	new POST(new Uri("http://www.enhanced-calm.com/upload/"))
		.Refine(new Header("Content-Type", "application/json"))
		.Refine(new FileStream("~/my-jsons/important-posting.json", FileMode.Read));

Render the response (asynchronously)

This is how you render a request to a response:

var response =
	await
		new GET(new Uri("http://www.enhanced-calm.com/newest-postings"))
			.Refine(new Header("Content-Type", "application/json"))
			.Render(new AspNetResponse());

And from there on, you can render the response to what you need. For example, json content:

var bodyText =
	await 
		new GET(new Uri("http://www.enhanced-calm.com/newest-postings"))
			.Refine(new Header("Content-Type", "application/json"))
			.Render(new AspNetResponse())
			.Render(new BodyAsText());

Http 2.0 and 3.0

For using Http 2.0/3.0 in your requests, take the objects in the WHyLL.Request.Http2 or WHyLL.Request.Http3 namespaces.

whyll's People

Contributors

meerownymous avatar

Stargazers

 avatar

Watchers

 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.