Code Monkey home page Code Monkey logo

graft-http's Introduction

Warning: This library is under active development, and should not be considered production ready

graft-http

Graft HTTP/REST integration

For now, this service is meant to provide the minimal amount of glue code needed to accomplish these objectives.

  1. Serve an HTTP request using a Graft-based back-end.
  2. Make an HTTP request with a Graft message.
  3. Cleaner way to bootstrap Graft websocket servers.

There is a lot of stream-based code out there that allows you to work with HTTP services, and we aim to be compatible with them.

graft-http's People

Contributors

adrianrossouw avatar tamagokun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

graft-http's Issues

request / response serialization to message

I wanted to start a new issue thread for figuring out how we will serialize requests and responses into graft messages.

I see 3 problems we need to solve:

  1. We need to be able to access important data in req. (url, params, etc)
  2. Set status code and headers on the response.
  3. Provide access to the req/res streams so you could pipe an http request/response somewhere else.

Below is an ongoing draft of what these message blocks would look like:

// request
{
    httpVersion:
    method:
    url:
    host:
    hostname:
    path:
    protocol:
    port:
    query:
    params:
    body: req
    res: graft.ReadChannel()
}


// response
{
    statusCode:
    headers:
    body: // string, buffer, stream
}

I think 1 and 2 are already solved, we just need to decide on the message properties. For 3, I don't know how to best handle this. We would have a request stream, response stream, but also a return channel? Is there a way to merge these somehow?

@GraftJS/graft-http-committers

http server

this is pretty much just a wrapper around http.createServer, that has a graft instance inside of it that it uses to resolve the request.

it will map the response into a returnChannel, and pass the message along.

It should allow you to use all the other stream-oriented http tools that exist, and stay the fsck out of everyone's way as much as possible.

bonus points: be able to pipe messages through a graft http request service, that has been piped into a locally running graft http server =P you know. for tests...

standard way to map an http server onto a stream.

So while thinking about the idea of authenticated streams using passport, and it occured to me that you just needed a standard way to represent an http request as a graft message. turn those messages into http requests , and turn the responses back into graft messages.

so you could mount an http server or express stack as a stream function. that would allow you to mount passport on it, and do some other pretty nifty things.

maybe even something like this for graft : http://hueniverse.com/2015/06/02/introducing-chairo-a-hapi-js-microservices-plugin/

http client

same thing as the http server, but probably a thin wrapper around mikael's request or substack's hyperquest.

bonus points: being able to pipe messages that get turned into http requests that can be piped into an graftified http server instance (you know, for tests =) )

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.