From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Zelphir Kaltstahl Newsgroups: gmane.lisp.guile.user Subject: Re: Web development Date: Fri, 4 Sep 2020 22:09:52 +0200 Message-ID: <28851dc6-d0a2-4b17-cf0c-c14571f02110@posteo.de> References: <874kodfq4h.fsf@elephly.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30183"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: guile-user@gnu.org To: Ricardo Wurmus Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri Sep 04 22:10:11 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kEI2E-0007gq-F0 for guile-user@m.gmane-mx.org; Fri, 04 Sep 2020 22:10:10 +0200 Original-Received: from localhost ([::1]:52606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEI2D-0002sG-I8 for guile-user@m.gmane-mx.org; Fri, 04 Sep 2020 16:10:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEI23-0002rs-Ju for guile-user@gnu.org; Fri, 04 Sep 2020 16:09:59 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:58767) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEI21-0008EI-1s for guile-user@gnu.org; Fri, 04 Sep 2020 16:09:59 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id C990516005C for ; Fri, 4 Sep 2020 22:09:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1599250193; bh=OeRJwYVTC9bPZH2jtPbGbiwd3+UhroSrs+Xx2SdK6jo=; h=Subject:To:Cc:From:Date:From; b=TxEkZvhrr4YXiv/mKj/mvOBZdLtaoOqU7uqxiNcgzA5MKNDHkq/Ln80/6WayJTVMA MYRWzbB3KIAK3OCaIHldKfI/FH7/peQPEkFEFTVfIj2DubEjB/m7nldrZ3umjB2ml6 59XpW/zBB/QCd+2btvUTiaXYTrNWG+XBRf83GWbRg+DRWb8tzJSKA7MbQNcnkMiV36 beqFpcdZ+n4dLR2SljEjyJbvjE0kxYn1v7ReShfld9BWs1u4HKjkto9yW1DTb6ZzC3 o82rVo3/6vb7s7lY664DQ0rcQJOG5KY1RizoofNWfWOSbl70ErTi6ex5mS0eFR3vwz etoaL8Diy80wQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4BjpgN5sCgz9rxX; Fri, 4 Sep 2020 22:09:52 +0200 (CEST) In-Reply-To: <874kodfq4h.fsf@elephly.net> Content-Language: en-US Received-SPF: pass client-ip=185.67.36.65; envelope-from=zelphirkaltstahl@posteo.de; helo=mout01.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 16:09:54 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.107, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16848 Archived-At: Hi Ricardo! On 9/4/20 6:44 PM, Ricardo Wurmus wrote: > Zelphir Kaltstahl writes: > >> So I have a few questions: >> >> (1) How do you do your Guile web development? What's the setup? > I don’t use a framework in my web projects; just the included web > modules and sometimes the fibers web server. I keep everything > stateless so that I can spin up many workers (i.e. Guile processes > with a web server listening on one of a range of local ports) and > dispatch to them from a reverse proxy such as Nginx or Lighttpd. > >> (2) What do you use to serve static files (securely)? If you use Guile's >> web server, how exactly do you do it? Do you have the code somewhere? > I configure an assets directory and define a procedure that sanitizes > the requested file name to serve it from that directory. I don’t do > much with files so I don’t usually do anything other than > > (call-with-input-file file-name get-bytevector-all) > > for the body of the response. But if I had to send large files I’d use > “sendfile” directly. Don't you need to also check what kind of file type it is and select the appropriate MIME type for answering the request? (Do you have some code public somewhere, showing how to do this?) And how do you use sendfile directly? (Code example for this would also be great to see.) (I've checked https://github.com/rekado and https://git.elephly.net/, but could not find a web server project.) Is it still necessary to sanitize the requested file names, when an HTTP server handles requests for assets before the Guile application is hit? >> (3) Perhaps there is a minimalistic option instead of NGINX or HAProxy >> out there, which is also free software? Is there perhaps even anything >> in Guile, which I could use, that is suitable for serving static files? > Lighttpd seems to be lighter than Nginx. If all you want is serve > static files upon request I’d use just Guile, matching on the request, > looking up the file in a declared directory, and using sendfile to push > it to the requester. Best regards, Zelphir