www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - D FCGI

reply James Miller <james aatch.net> writes:
Hello everybody,

Before I essentially spam everybody, I'll introduce myself. I am James
Miller, and English developer living in New Zealand, I started using D
about 2 months ago and am currently working on a large project using
it.

As part of that project, I developed a FastCGI library (mostly because
FastCGI4D won't work with D2 for various reasons). I have now released
that library, and it currently lives on GitHub.

Without much further ado, let me introduce to you:

D FCGI, a FastCGI library for D.
http://www.github.com/Aatch/dfcgi/

It is basically just a wrapper for the fcgiapp functions in libfcgi
(and as such requires libfcgi to compile). I have tried to make it
simple to use without sacrificing functionality.

I'm fairly new to D, so any feedback on general code quality would be
appreciated.
Feb 03 2012
next sibling parent reply David Nadlinger <see klickverbot.at> writes:
General note: You might want to submit the libfcgi header part to Deimos 
(there is even a project for it already, albeit empty: [1]), and then 
build the convenience functions on top of it. This way, we can avoid 
duplication of efforts if somebody wants to use the C interface directly.

David


[1] https://github.com/D-Programming-Deimos/libfcgi

On 2/3/12 1:31 PM, James Miller wrote:
 Hello everybody,

 Before I essentially spam everybody, I'll introduce myself. I am James
 Miller, and English developer living in New Zealand, I started using D
 about 2 months ago and am currently working on a large project using
 it.

 As part of that project, I developed a FastCGI library (mostly because
 FastCGI4D won't work with D2 for various reasons). I have now released
 that library, and it currently lives on GitHub.

 Without much further ado, let me introduce to you:

 D FCGI, a FastCGI library for D.
 http://www.github.com/Aatch/dfcgi/

 It is basically just a wrapper for the fcgiapp functions in libfcgi
 (and as such requires libfcgi to compile). I have tried to make it
 simple to use without sacrificing functionality.

 I'm fairly new to D, so any feedback on general code quality would be
 appreciated.
Feb 03 2012
parent reply James Miller <james aatch.net> writes:
On Feb 4, 2012 5:31 AM, "David Nadlinger" <see klickverbot.at> wrote:
 General note: You might want to submit the libfcgi header part to Deimos
(there is even a project for it already, albeit empty: [1]), and then build the convenience functions on top of it. This way, we can avoid duplication of efforts if somebody wants to use the C interface directly.
 David


 [1] https://github.com/D-Programming-Deimos/libfcgi
Good idea, if I write more headers for it, then I should be able to port the examples from the fcgi dev kit to D on top of it.
Feb 03 2012
parent Walter Bright <newshound2 digitalmars.com> writes:
On 2/3/2012 3:20 PM, James Miller wrote:
 On Feb 4, 2012 5:31 AM, "David Nadlinger" <see klickverbot.at
 <mailto:see klickverbot.at>> wrote:
  >
  > General note: You might want to submit the libfcgi header part to Deimos
 (there is even a project for it already, albeit empty: [1]), and then build the
 convenience functions on top of it. This way, we can avoid duplication of
 efforts if somebody wants to use the C interface directly.
  >
  > David
  >
  >
  > [1] https://github.com/D-Programming-Deimos/libfcgi

 Good idea, if I write more headers for it, then I should be able to port the
 examples from the fcgi dev kit to D on top of it.
Yes, please.
Feb 04 2012
prev sibling next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
 D FCGI, a FastCGI library for D.
I've also done something similar: https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff check out cgi.d. If you compile with -version=fastcgi, it uses the libfcgi while keeping the same interface as the default regular CGI.
Feb 03 2012
parent reply James Miller <james aatch.net> writes:
On Feb 4, 2012 5:38 AM, "Adam D. Ruppe" <destructionator gmail.com> wrote:
 D FCGI, a FastCGI library for D.
I've also done something similar:
https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff
 check out cgi.d. If you compile with -version=fastcgi, it
 uses the libfcgi while keeping the same interface as the
 default regular CGI.
I haven't looked at any of the files yet, but the fact that you have a set of database modules looks useful. I'll also take a look at how you are handling things in cgi.d and see if I can improve things in my code from there. I wish this kind of stuff was easier to find, putting D <something> in a search almost never returns anything useful. DSource seems pretty useless as half the projects haven't been worked on in a while and/or don't work with D2. I could go on, but don't want to derail my own topic...
Feb 03 2012
next sibling parent reply "Adam D. Ruppe" <destructionator gmail.com> writes:
On Friday, 3 February 2012 at 23:15:19 UTC, James Miller wrote:
 I haven't looked at any of the files yet, but the fact that you 
 have a set of database modules looks useful.
Yeah, I used to use php but wanted to ditch it for D, so everything I needed from php I did in D too, and have since moved beyond that as well (the other modules give higher level wrappers, html dom stuff, and more.)
 I'll also take a look at how you are
 handling things in cgi.d and see if I can improve things in my
Two things I noticed your thing didn't do (unless I missed it) was arrays of parameters and uploaded files. Arrays of params is easy: in the query string or the POST data, the names are simply repeated, so you can use a string[][string] and append to it. File uploads were a pain to implement, since it uses MIME encoding, but still not too awful. You can take whatever you want from my code.
 I wish this kind of stuff was easier to find, putting D 
 <something> in a search almost never returns anything useful.
Aye.
Feb 03 2012
parent reply James Miller <james aatch.net> writes:
Two things I noticed your thing didn't do (unless I missed it)
was arrays of parameters and uploaded files.
I parse the GET params, POST params, and FCGI Params and store them in _getParams, _postParams and _environment respectively. I also duplicate the GET and POST params into _requestParams (not that memory efficient, but I can always optimize if it becomes a problem). All of those are string[string] associative arrays. Is that what you mean? I don't know what more information I can feasibly grab from the request... I didn't think about file uploads. I'd have to implement them eventually so knowing that you handled it at least gives me something to start from, thanks.
Yeah, I used to use php but wanted to ditch it for D,
What a coincidence, me too!
Feb 03 2012
parent "Adam D. Ruppe" <destructionator gmail.com> writes:
On Saturday, 4 February 2012 at 04:37:57 UTC, James Miller wrote:
 I parse the GET params, POST params, and FCGI Params and store 
 them in _getParams, _postParams and _environment
Yeah, that works for the vast majority of cases, but suppose you go to: yoursite.com/yourapp?foo=bar&foo=baz That's allowed and sometimes useful. In PHP, you'd name a form field "something[]" and access it as an array of multiple values. The PHP name thing is just something they do; you can actually send multiple values for any name, and sometimes you'll want to be able to access that too. In my thing, I used a string[string] for get, but also offered a string[][string] called getArray for the times when you want to get to multiple values. (ditto for POST)
 What a coincidence, me too!
D rox.
Feb 03 2012
prev sibling next sibling parent Trass3r <un known.com> writes:
 I wish this kind of stuff was easier to find, putting D <something> in a
 search almost never returns anything useful. DSource seems pretty useless
Yeah, we should establish dlang as a search term.
Feb 04 2012
prev sibling parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Friday, 3 February 2012 at 23:15:19 UTC, James Miller wrote:
 I wish this kind of stuff was easier to find, putting D 
 <something> in a search almost never returns anything useful.
This works quite well: https://www.google.com/search?q=%22d+programming%22+fastcgi
Feb 04 2012
parent James Miller <james aatch.net> writes:
On 5 February 2012 09:42, Vladimir Panteleev
<vladimir thecybershadow.net> wrote:
 This works quite well:

 https://www.google.com/search?q=%22d+programming%22+fastcgi
I like how my library is about 7th :D Back on topic: I have now written bindings for deimos.fcgi as suggested, I'm currently working on porting a couple of the examples and then I'll try to fill in the README. I have no idea what to do in terms of build scripts or Makefiles or anything, as I have no experience with this kind of thing. Any help would be appreciated. Thanks
Feb 04 2012
prev sibling parent reply Nick_B <nick.NOSPAMbarbalich gmail.com> writes:
On 4/02/2012 1:31 a.m., James Miller wrote:
 Before I essentially spam everybody, I'll introduce myself. I am James
 Miller, and English developer living in New Zealand, I started using D
 about 2 months ago and am currently working on a large project using
 it.
Hi James where in NZ are you ? why did you pick D for this large project ? what industry are you in ? regards Nick _B
Feb 03 2012
parent James Miller <james aatch.net> writes:
On 4 February 2012 14:07, Nick_B <nick.NOSPAMbarbalich gmail.com> wrote:
 On 4/02/2012 1:31 a.m., James Miller wrote:
 Before I essentially spam everybody, I'll introduce myself. I am James
 Miller, and English developer living in New Zealand, I started using D
 about 2 months ago and am currently working on a large project using
 it.
Hi James where in NZ are you ? why did you pick D for this large project ? what industry are you in ? regards Nick _B
Hey Nick. I am in Wellington. I'm using D because I feel it needs more exposure and usage and this was a good opportunity to do so. I make a living writing PHP, and until recently have worked freelance. I now have a permanent position at a start-up as a web developer. -- James Miller
Feb 03 2012