Created
November 20, 2008 18:53
-
-
Save lifo/27142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[lifo@null rock (master)]$ ruby extconf.rb && make | |
[lifo@null rock (master)]$ ruby run.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mkmf' | |
extension_name = 'rock' | |
dir_config(extension_name) | |
create_makefile(extension_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ruby.h" | |
VALUE method_call(VALUE self, VALUE env) { | |
VALUE response = rb_ary_new(); | |
VALUE headers = rb_hash_new(); | |
rb_hash_aset(headers, rb_str_new2("Content-Type"), rb_str_new2("text/html")); | |
rb_ary_push(response, INT2NUM(200)); | |
rb_ary_push(response, headers); | |
rb_ary_push(response, rb_str_new2("Hello Rock")); | |
return response; | |
} | |
void Init_rock() { | |
VALUE Rock = rb_define_class("Rock", rb_cObject); | |
rb_define_method(Rock, "call", method_call, 1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rock' | |
require 'rubygems' | |
require 'rack' | |
require 'thin' | |
Rack::Handler::Thin.run Rock.new, :Port => 9292 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment