From: "Roberto De Ioris" <roberto@unbit.it>
To: rack-devel@googlegroups.com
Subject: Re: Write an adapter in C
Date: Sat, 16 Jun 2012 07:52:42 +0200 [thread overview]
Message-ID: <a26b9103c3359566dba8db42084b1c14.squirrel@manage.unbit.it> (raw)
In-Reply-To: <ec77ead9-6f4f-40b6-b222-50069159d145@googlegroups.com>
> Hi, I would try to write an adapter for G-WAN server, which can run
> c-scripts. This is a G-WAN handler:
>
> #include "gwan.h" // G-WAN exported functions#include <string.h> //
> memcmp()
> int main(int argc, char *argv[])
> {
> char *query = get_env(argv, QUERY_STRING, 0); // query: "start=200000"
> if(!query || memcmp(query, "start=", sizeof("start=") - 1)) // FLV
> query?
> return 200; // HTTP status (200:'OK')
>
> http_t *head = get_env(argv, HTTP_HEADERS, 0); // set HTTP bytes range
> head->h_range_from = atol(query + sizeof("start=") - 1); // checked by
> G-WAN
>
> #define FLV_HEAD "FLV\x1\x1\0\0\0\x9\0\0\0\x9" // insert the FLV Header
> http_header(HEAD_ADD | HEAD_AFTER, FLV_HEAD, sizeof(FLV_HEAD) - 1,
> argv);
> return 206; // HTTP status (206:'Partial Content')
> }
>
>
> I could exchange data with Rack from a module like that. I do not how to
> write a Rack adapter, is there any tutorial. Should I call Ruby code from
> C, so should I write an wrapper to Rack methods?
>
Are you sure this is the best way to follow ?
Just to give you an idea on the amount of code you need:
http://projects.unbit.it/uwsgi/browser/plugins/rack/rack_plugin.c
gwan can proxy to http service, why not simply using
rackup,unicorn,uWSGI,thin behind gwan ?
--
Roberto De Ioris
http://unbit.it
prev parent reply other threads:[~2012-06-16 5:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-15 14:48 Write an adapter in C Riccardo Tacconi
2012-06-16 5:52 ` Roberto De Ioris [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://groups.google.com/group/rack-devel
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a26b9103c3359566dba8db42084b1c14.squirrel@manage.unbit.it \
--to=rack-devel@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).