Skip to content

Commit

Permalink
cleanup and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Dec 22, 2024
1 parent c42c613 commit 1a92a1e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
7 changes: 4 additions & 3 deletions examples/config.nru
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# This is both a NeoRack and a Rack application.
# This is a NeoRack Application with a Rack fallback for non-NeoRack servers (such as Puma).
#
# Iodine can run both Rack and NeoRack applications.
# Iodine can run both Rack (old school) and NeoRack applications.
#
# In this case the `on_http` implementation will be prioritized over the `call` implementation.
# In this case the `on_http` implementation will be called by iodine (and the `call` implementation will be called by any other server).
#
# Benchmark with keep-alive:
#
Expand All @@ -23,6 +23,7 @@
# listener.onevent = (e) => { console.log(e); }
#
module App
# for non-NeoRack servers, such as Puma
def self.call(e)
txt = []
if e['rack.upgrade?']
Expand Down
20 changes: 20 additions & 0 deletions examples/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,23 @@ module App
end

run App

# Benchmark with keep-alive:
#
# ab -c 200 -t 4 -n 1000000 -k http://127.0.0.1:3000/
# wrk -c200 -d4 -t2 http://localhost:3000/
#
# Connect to chat server with WebSockets:
#
# ws = new WebSocket("ws://" + document.location.host + document.location.pathname);
# ws.onmessage = function(e) {console.log("Got message!"); console.log(e.data);};
# ws.onclose = function(e) {console.log("closed")};
# ws.onopen = function(e) {ws.send("hi");};
#
# Listen to chat messages with Server Sent Events (EventSource / SSE):
#
# const listener = new EventSource(document.location.href);
# listener.onmessage = (e) => { console.log(e); }
# listener.addEventListener("time", (e) => { console.log(e); })
# listener.addEventListener("event", (e) => { console.log(e); })

1 change: 1 addition & 0 deletions ext/iodine/fio-stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43765,6 +43765,7 @@ FIO_SFUNC void fio_http_mime_register_essential(void) {
REGISTER_MIME("mjs", "text/javascript");
REGISTER_MIME("mp3", "audio/mpeg");
REGISTER_MIME("mp4", "video/mp4");
REGISTER_MIME("m4a", "audio/mp4");
REGISTER_MIME("m4v", "video/mp4");
REGISTER_MIME("mpeg", "video/mpeg");
REGISTER_MIME("mpkg", "application/vnd.apple.installer+xml");
Expand Down
1 change: 1 addition & 0 deletions ext/iodine/iodine.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void Init_iodine(void) {
/** The Iodine::Base module is for internal concerns. */
iodine_rb_IODINE_BASE =
rb_define_class_under(iodine_rb_IODINE, "Base", rb_cObject);
rb_undef_alloc_func(iodine_rb_IODINE_BASE);
STORE.hold(iodine_rb_IODINE_BASE);
/** The Iodine::Base::App404 module is for static file only. */
iodine_rb_IODINE_BASE_APP404 =
Expand Down
4 changes: 1 addition & 3 deletions ext/iodine/iodine_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,7 @@ static VALUE iodine_handler_deafult_on_http404(VALUE handler, VALUE client) {
iodine_connection_s *c = iodine_connection_ptr(client);
if (!c->http)
return Qnil;
fio_http_status_set(c->http, 404);
fio_http_finish(c->http);
// fio_http_send_error_response(c->http, 404);
fio_http_send_error_response(c->http, 404);
return Qnil;
(void)handler;
}
Expand Down

0 comments on commit 1a92a1e

Please sign in to comment.