Code Monkey home page Code Monkey logo

Comments (1)

vinniefalco avatar vinniefalco commented on May 8, 2024

First of all thank you for your interest in Beast! Those are some great questions. Answers:

Adding checks or defaults for missing fields would incur a run-time penalty. It is presumed that callers correctly fill out the message structure before invoking HTTP algorithms. I could add some asserts though, but that would only help debug builds.

Beast HTTP is intentionally a low level library. From http://vinniefalco.github.io/beast/beast/http/scope.html

"This library is designed to be a building block for creating higher level libraries. It is not designed to be end-user facing. There is no convenient class that implements the core of a web server, nor is there a convenient class to quickly perform common operations such as fetching a file or connecting and retrieving a document from a secure connection. These use-cases are important, but this library does not try to do that. Instead, it offers primitives that can be used to build those user-facing algorithms."

I agree that very common use cases require more lines than usual. It is my hope that other developers will use Beast as a building block to create those user-facing algorithms. For example, someone suggested that having a C++ library modeled after Python Requests (http://docs.python-requests.org/en/master/) would be helpful. I hope that someone will build that library on top of Beast.

The explicit call to beast::http::prepare is not required. It is just a convenience function that fills in some of the fields for you. For example, it will set the Content-Length field, Transfer-Encoding, and Connection fields appropriately. If you want to set those fields yourself and skip the call to prepare, you can do it.

To extend the message structure, it is best to use composition. Create a new struct or class that has the message as a data member. Custom algorithms that take this new type as a parameter can be in their own namespace, and call Beast algorithms as required. I'm not sure if an example of "using middleware" is warranted - such an example would serve no purpose other than to inform readers of how to use object composition, which is assumed knowledge.

from beast.

Related Issues (20)

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.