The loli package

[Tags: bsd3, deprecated, library]

Deprecated in favor of miku

A simple library for fast web prototyping in Haskell.


[Skip to ReadMe]

Properties

Versions2009.6.25, 2009.6.26, 2009.6.27, 2009.6.29, 2009.7.2, 2009.8.16, 2009.8.18, 2009.10.13, 2010.10.9, 2011.6.24
Change logchangelog.md
Dependenciesbase (>4 && <=5), bytestring, containers, data-default, hack (>=2009.7.15), hack-contrib (>=2009.8.18), mps (>=2009.9.18), mtl, template (<0.2), utf8-string [details]
LicenseBSD3
AuthorJinjing Wang
MaintainerJinjing Wang <nfjinjing@gmail.com>
CategoryWeb
Home pagehttp://github.com/nfjinjing/loli
UploadedFri Jun 24 05:06:41 UTC 2011 by JinjingWang
Downloads1428 total (66 in last 30 days)
Votes
0 []
StatusDocs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for loli-2011.6.24

loli

A minimum web dev DSL

Example

import Network.Loli
import Hack.Handler.Happstack

main = run . loli $ get "/" (text "loli power")

Installation

cabal update
cabal install loli
cabal install hack-handler-happstack

-- copy and paste the above example to myapp.hs

ghc --make myapp.hs
./myapp

check: http://localhost:3000

Quick reference

http://github.com/nfjinjing/loli/blob/master/src/Test/Test.hs

Routes

Verbs

-- use - instead of $ for clarity
import MPS.Light ((-))
import Prelude hiding ((-))

import Network.Loli
import Hack.Handler.Happstack

main = run . loli - do

  get "/" - do
    -- something for a get request

  post "/" - do
    -- for a post request

  put "/" - do
    -- put ..

  delete "/" - do
    -- ..

Captures

get "/say/:user/:message" - do
  text . show =<< captures

-- /say/jinjing/hello will output
-- [("user","jinjing"),("message","hello")]

Static

-- public serve, only allows `./src`
public (Just ".") ["/src"]

Mime types

-- treat .hs extension as text/plain
mime "hs" "text/plain"

Filters

-- before takes a function of type (Env -> IO Env)
before - \e -> do
  putStrLn "before called"
  return e

-- after takes that of type (Response -> IO Response)
after return

Hack integration

Use hack middleware

-- note both etag and lambda middleware are removed ... for somce ghc 7.0 compatability ><

import Hack.Contrib.Middleware.ETag
import Hack.Contrib.Middleware.Lambda

middleware etag
middleware lambda

Convert loli into a hack application

-- in Network.Loli.Engine

loli :: Unit -> Application

Hints

Reference

<br/> <p> <a href="http://en.wikipedia.org/wiki/Shinryaku!_Ika_Musume"><img src="https://github.com/nfjinjing/loli/raw/master/ita.jpg"/></a> </p>