All Projects → thomasp85 → Fiery

thomasp85 / Fiery

Licence: other
A flexible and lightweight web server

Programming Languages

r
7636 projects

Projects that are alternatives of or similar to Fiery

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 (+295.07%)
Mutual labels:  websocket-server, http-server, webserver
Iodine
iodine - HTTP / WebSockets Server for Ruby with Pub/Sub support
Stars: ✭ 720 (+254.68%)
Mutual labels:  websocket-server, http-server, webserver
Libhv
🔥 比libevent、libuv更易用的国产网络库。A c/c++ network library for developing TCP/UDP/SSL/HTTP/WebSocket client/server.
Stars: ✭ 3,355 (+1552.71%)
Mutual labels:  websocket-server, http-server, webserver
Nico
A HTTP2 web server for reverse proxy and single page application, automatically apply for ssl certificate, Zero-Configuration.
Stars: ✭ 43 (-78.82%)
Mutual labels:  http-server, webserver
Webcpp
用C++开发web服务器框架
Stars: ✭ 23 (-88.67%)
Mutual labels:  http-server, webserver
Jiny
Lightweight, modern, simple JVM web framework for rapid development in the API era
Stars: ✭ 40 (-80.3%)
Mutual labels:  websocket-server, http-server
Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+3118.23%)
Mutual labels:  websocket-server, http-server
Suave
Suave is a simple web development F# library providing a lightweight web server and a set of combinators to manipulate route flow and task composition.
Stars: ✭ 1,196 (+489.16%)
Mutual labels:  http-server, webserver
Vtx clientserver
VTX Client / Server package.
Stars: ✭ 60 (-70.44%)
Mutual labels:  websocket-server, http-server
Igropyr
a async http server base on libuv for Chez Scheme
Stars: ✭ 85 (-58.13%)
Mutual labels:  http-server, webserver
Octane
A web server modeled after express in Rust.
Stars: ✭ 136 (-33%)
Mutual labels:  http-server, webserver
Sylar
C++高性能分布式服务器框架,webserver,websocket server,自定义tcp_server(包含日志模块,配置模块,线程模块,协程模块,协程调度模块,io协程调度模块,hook模块,socket模块,bytearray序列化,http模块,TcpServer模块,Websocket模块,Https模块等, Smtp邮件模块, MySQL, SQLite3, ORM,Redis,Zookeeper)
Stars: ✭ 895 (+340.89%)
Mutual labels:  websocket-server, http-server
Facil.io
Your high performance web application C framework
Stars: ✭ 1,393 (+586.21%)
Mutual labels:  websocket-server, webserver
Pure Http
✨ The simple web framework for Node.js with zero dependencies.
Stars: ✭ 139 (-31.53%)
Mutual labels:  http-server, webserver
Embedio
A tiny, cross-platform, module based web server for .NET
Stars: ✭ 1,007 (+396.06%)
Mutual labels:  http-server, webserver
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 (+293.6%)
Mutual labels:  websocket-server, http-server
Jennet
A simple HTTP web framework written in Pony
Stars: ✭ 72 (-64.53%)
Mutual labels:  http-server, webserver
Swoft
🚀 PHP Microservice Full Coroutine Framework
Stars: ✭ 5,420 (+2569.95%)
Mutual labels:  websocket-server, http-server
Proxy.py
⚡⚡⚡Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on Network monitoring, controls & Application development, testing, debugging
Stars: ✭ 1,291 (+535.96%)
Mutual labels:  http-server, webserver
Rayo.js
Micro framework for Node.js
Stars: ✭ 170 (-16.26%)
Mutual labels:  http-server, webserver

Lifecycle: stable Travis-CI Build Status AppVeyor Build Status CRAN_Status_Badge CRAN_Download_Badge Coverage Status

Fiery is a flexible and lightweight framework for building web servers in R. It is relatively unopinionated about how you chose to build your server logic and supports many use cases, from serving static files to being used as a base for a model-view-controller based setup.

The shiny elephant in the room

Before going any further I will briefly address what most people are thinking of when they think R+web: Shiny:

Is this a competing framework to Shiny?

In a way, yes. Any package that provides functionality for creating web applications in R will be competing for the developers who wish to make web apps. This is of course reinforced by the name of the package, which is a gently jab at Shiny. But mostly no. I believe Shiny and Fiery will appeal to vastly different use cases, in the same way as automakers and motorbike makers are in theory competing for the customers who wish to acquire the means to transport themselves, but would never be seen as truly competing.

So what is so different about Fiery?

Without falling too much into the trap of defining a project by how it differs from another, there are some very clear differences in approach between Fiery and Shiny.

  • Shiny uses magic to make everything work from R, Fiery lets you do all the hard work.
  • Shiny wants the main app-logic to be server-side, Fiery don’t care what you do.
  • Shiny uses a reactive model to define the app-logic, Fiery don’t care what you do (see a pattern emerge).
  • Shiny wants you to use htmltools to build the html, Fiery really don’t care what you use.

From the above it is quite clear that Fiery to a higher degree gives you the choice and responsibility of building up your app at the cost of higher complexity, but with the goal of giving you more power over what you can do.

So how is this different from httpuv?

Now we’re getting somewhere! httpuv is sitting in the bottom of the stack for both Shiny and Fiery, but where Shiny build an elaborate, opinionated and complete framework on top of httpuv, Fiery “merely” adds a lot of convenience to running a httpuv based web server. You could say that Fiery sits between httpuv and Shiny, and that Shiny (or an alternative framework) could in theory be build on top of Fiery.

How to install this

Install the release from CRAN using install.packages('fiery') or get the development version directly from GitHub using devtools:

# install.packages('devtools')
devtools::install_github('thomasp85/fiery')

Design

Fiery is designed around a clear server life-cycle with events being triggered at specific points during the life-cycle that will call the handlers attached to these events. In addition to the life-cycle events, it is possible to trigger custom events and attach handlers to these as well. Fiery is designed with modularity in mind so that plugins can be developed for different tasks and mixed and matched to suit the specific project.

While the intro might indicate that fiery is difficult to use, this is not the case. Much of the hard work of handling http requests has been encapsulated in the reqres that fiery uses to handle http requests and responses. Further, A plugin that will often be used is routr, which provides powerful routing of HTTP requests, thus simplifying the server logic even more.

A minimal example

Following is a very Hello World-ish example of a fiery app (sans routr), that showcases some of the different life-cycle events:

library(fiery)

# Create a New App
app <- Fire$new()

# Setup the data every time it starts
app$on('start', function(server, ...) {
    server$set_data('visits', 0)
    server$set_data('cycles', 0)
})

# Count the number of cycles (internal loops)
app$on('cycle-start', function(server, ...) {
    server$set_data('cycles', server$get_data('cycles') + 1)
})

# Count the number of requests
app$on('before-request', function(server, ...) {
    server$set_data('visits', server$get_data('visits') + 1)
})

# Handle requests
app$on('request', function(server, request, ...) {
    response <- request$respond()
    response$status <- 200L
    response$body <- paste0('<h1>This is indeed a test. You are number ', server$get_data('visits'), '</h1>')
    response$type <- 'html'
})

# Show number of requests in the console
app$on('after-request', function(server, ...) {
    message(server$get_data('visits'))
    flush.console()
})

# Terminate the server after 50 cycles
app$on('cycle-end', function(server, ...) {
    if (server$get_data('cycles') > 50) {
        message('Ending...')
        flush.console()
        server$extinguish()
    }
})

# Be polite
app$on('end', function(server) {
    message('Goodbye')
    flush.console()
})

app$ignite(showcase = TRUE)
#> Fire started at 127.0.0.1:8080
#> message: 1
#>  from message(server$get_data("visits"))
#> message: Goodbye
#>  from message("Goodbye")

In general much of the logic will happen in the request and message handlers and you are free to ignore the other life-cycle events if they are not needed.

Feedback

I would love some feedback on this - open an issue or reach out to me on twitter.

Code of Conduct

Please note that the ‘fiery’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

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].