@hackage chu22012.11.18.2

FFI for Chu2 Agda Web Server Interface

Chu2 Agda Web Server Interface

hello world example

module Hello where

open import IO.Primitive    using (return)
open import Data.List       using ([])
open import Chu2.ByteString using (pack)
open import Function        using (_$_; const)
open import Chu2            using (response; OK; Application) 

hello-world-response = response OK [] (pack "Hello Agda!")

hello-world-app : Application
hello-world-app = const $ return hello-world-response

open import Chu2.Handler.SnapServer using (on-port_run)
main = on-port 3000 run hello-world-app

Using Middleware

module Hello2 where

-- simple-logger middleware
open import Chu2.Middleware.SimpleLogger using (simple-logger)

open import IO.Primitive    using (return)
open import Function        using (const)
open import Chu2            using (Application; defaultResponse; RawMiddleware)

-- https://github.com/nfjinjing/gumi
open import Gumi.Light      using (_-_)

hello-world-app : Application
hello-world-app = const - return defaultResponse

open import Chu2.Handler.SnapServer using (on-port_run)
main = on-port 3001 run - simple-logger hello-world-app

Note