;; This an Artanis ENTRY file, don't remove it! (use-modules (artanis artanis) ;; Put modules you want to be imported here ;; only for this file, not controllers/views (artanis utils)) (use-modules (srfi srfi-71) (artanis artanis) (web uri) (web client) (web request)) ;; Put whatever you want to be called before server initilization here (init-server #:statics '(png gif jpg jpeg ico html js json csv xml css woff woff2 ttf)) (add-to-load-path (string-append (current-toplevel) "/lib")) ;; Put whatever you want to be called before server running here (define* (get-content #:key non-blocking?) (let* ((uri (string->uri (string-append ;; No HTTPS because Guile/Guile GnuTLS doesn't ;; support TLS handshakes on a non blocking socket ;; yet "http://data.guix.gnu.org" "/revision/e5478c6acf74c3d5b1d25125baac23171403bd1d" "/packages.json?locale=en_US.UTF-8&field=version&field=synopsis&limit_results=100"))) (socket (open-socket-for-uri uri))) (when non-blocking? (fcntl socket F_SETFL (logior O_NONBLOCK (fcntl socket F_GETFL)))) (let ((response body (http-get uri #:port socket #:streaming? #t))) (json->scm body)))) (get "/" (lambda () (simple-format #f "~A" (get-content #:non-blocking? #t)))) (get "/working" (lambda () (simple-format #f "~A" (get-content #:non-blocking? #f))))