All Projects → webmachine → Webmachine Ruby

webmachine / Webmachine Ruby

Licence: other
Webmachine, the HTTP toolkit (in Ruby)

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Webmachine Ruby

Tufao
An asynchronous web framework for C++ built on top of Qt
Stars: ✭ 513 (-38.34%)
Mutual labels:  http-server
Swiftengine
Apple Swift based HTTP server. The answer for a Swift based, turn key, crash resilient, high scale, and production grade web server.
Stars: ✭ 660 (-20.67%)
Mutual labels:  http-server
Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+685.22%)
Mutual labels:  http-server
Lithium
Easy to use C++17 HTTP Server with no compromise on performances. https://matt-42.github.io/lithium
Stars: ✭ 523 (-37.14%)
Mutual labels:  http-server
Drogon
Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
Stars: ✭ 6,567 (+689.3%)
Mutual labels:  http-server
Cutelyst
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Stars: ✭ 671 (-19.35%)
Mutual labels:  http-server
Url2img
HTTP server with API for capturing screenshots of websites
Stars: ✭ 495 (-40.5%)
Mutual labels:  http-server
Beetlex
high performance dotnet core socket tcp communication components, support TLS, HTTP, HTTPS, WebSocket, RPC, Redis protocols, custom protocols and 1M connections problem solution
Stars: ✭ 802 (-3.61%)
Mutual labels:  http-server
Swoft
🚀 PHP Microservice Full Coroutine Framework
Stars: ✭ 5,420 (+551.44%)
Mutual labels:  http-server
Iodine
iodine - HTTP / WebSockets Server for Ruby with Pub/Sub support
Stars: ✭ 720 (-13.46%)
Mutual labels:  http-server
Cppserver
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Stars: ✭ 528 (-36.54%)
Mutual labels:  http-server
Poco
The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
Stars: ✭ 5,762 (+592.55%)
Mutual labels:  http-server
Zaver
Yet another fast and efficient HTTP server
Stars: ✭ 673 (-19.11%)
Mutual labels:  http-server
Apfree wifidog
A hight performance and lightweight captive portal solution for HTTP(s)
Stars: ✭ 519 (-37.62%)
Mutual labels:  http-server
Hug
Embrace the APIs of the future. Hug aims to make developing APIs as simple as possible, but no simpler.
Stars: ✭ 6,572 (+689.9%)
Mutual labels:  http-server
Http
Event-driven, streaming HTTP client and server implementation for ReactPHP.
Stars: ✭ 507 (-39.06%)
Mutual labels:  http-server
Takes
True Object-Oriented Java Web Framework
Stars: ✭ 670 (-19.47%)
Mutual labels:  http-server
Httpserver
Python 3 implementation of an HTTP server
Stars: ✭ 5 (-99.4%)
Mutual labels:  http-server
Netcoreserver
Ultra fast and low latency asynchronous socket server & client C# .NET Core library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Stars: ✭ 799 (-3.97%)
Mutual labels:  http-server
Restinio
Cross-platform, efficient, customizable, and robust asynchronous HTTP/WebSocket server C++14 library with the right balance between performance and ease of use
Stars: ✭ 694 (-16.59%)
Mutual labels:  http-server

webmachine for Ruby

Gem Version Build Status

webmachine-ruby is a port of Webmachine, which is written in Erlang. The goal of both projects is to expose interesting parts of the HTTP protocol to your application in a declarative way. This means that you are less concerned with the procedures involved in handling requests directly and more with describing facts about the resources that make up your application. Webmachine is not a web framework per se, but more of a toolkit for building HTTP-friendly applications. For example, it does not provide a templating engine or a persistence layer; those choices are up to you.

Features

  • Handles the hard parts of content negotiation, conditional requests, and response codes for you.
  • Provides a base resource with points of extension to let you describe what is relevant about your particular resource.
  • Supports WEBrick, Reel, HTTPkit, and a Rack shim. Other host servers are being investigated.
  • Streaming/chunked response bodies are permitted as Enumerables, Procs, or Fibers!
  • Unlike the Erlang original, it does real Language negotiation.
  • Includes a visual debugger so you can look through the decision graph to determine how your resources are behaving.

Documentation & Finding Help

Getting Started

Below we go through some examples of how to do basic things with webmachine-ruby.

The first example defines a simple resource that doesn't demo the true power of Webmachine but perhaps gives a feel for how a Webmachine resource might look. Webmachine::Resource.run is available to provide for quick prototyping and development. In a real application you will want to configure what path a resource is served from. See the Router section in the README for more details on how to do that.

There are many other HTTP features exposed to a resource through {Webmachine::Resource::Callbacks}. A callback can alter the outcome of the decision tree Webmachine implements, and the decision tree is what makes Webmachine unique and powerful.

A simple static HTML resource

require 'webmachine'

class MyResource < Webmachine::Resource
  def to_html
    "<html><body>Hello, world!</body></html>"
  end
end

# Start a web server to serve requests via localhost
MyResource.run

A simple dynamic JSON Resource

require 'webmachine'
require 'widget'

class MyResource < Webmachine::Resource

  # GET and HEAD are allowed by default, but are shown here for clarity.
  def allowed_methods
    ['GET','HEAD']
  end

  def content_types_provided
    [['application/json', :to_json]]
  end

  # Return a Truthy or Falsey value
  def resource_exists?
    widget
  end

  def widget
    @widget ||= Widget.find(request.path_info[:id])
  end

  def to_json
    widget.to_json
  end
end

Router

The router is used to map a resource to a given path. To map the class MyResource to the path /myresource you would write something along the lines of:

Webmachine.application.routes do
  add ['myresource'], MyResource
end

# Start a web server to serve requests via localhost
Webmachine.application.run

When the resource needs to be mapped with variables that will be passed into the resource, use symbols to identify which path components are variables.

Webmachine.application.routes do
  add ['myresource', :id], MyResource
end

To add more components to the URL mapping, simply add them to the array.

Webmachine.application.routes do
  add ['myparentresource', :parent_id, 'myresource', :id], MyResource
end

Read more about routing here.

Application/Configurator

There is a configurator that allows you to set what IP address and port a web server should bind to as well as what web server should serve a webmachine resource. Learn how to configure your application here.

Adapters

Webmachine provides adapters for many popular webservers. Learn more here.

Visual debugger

It can be hard to understand all of the decisions that Webmachine makes when servicing a request to your resource, which is why we have the "visual debugger". Learn how to configure it here.

Related libraries

LICENSE

webmachine-ruby is licensed under the Apache v2.0 license. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].