Changes between Version 6 and Version 7 of HackageDB/2.0/Architecture

Show
Ignore:
Timestamp:
08/08/10 06:37:48 (3 years ago)
Author:
mgruen
Comment:

ah, pre doesn't need link escaping

Legend:

Unmodified
Added
Removed
Modified
  • HackageDB/2.0/Architecture

    v6 v7  
    1515lines of source code. 
    1616 
    17 This is a work in progress, somewhat unorganized. Nearly everything here was 
     17This is a work in progress. Nearly everything here was 
    1818implemented this past summer (2010). 
    1919 
     
    9797[(String, String)]. 
    9898 
    99 To define a basic blog post Resource, you would write (todo: link happstack docs): 
     99To define a basic blog post Resource, you would write: 
    100100 
    101101{{{ 
     
    103103blogPost = (resourceAt "/blog/post/:id") { resourceGet = [("txt", serveBlogPost)], resourcePut = [("txt", setBlogPost)]} 
    104104 
    105 serveBlogPost :: !DynamicPath -> !ServerPart Response 
     105serveBlogPost :: DynamicPath -> ServerPart Response 
    106106serveBlogPost dpath = case fromReqURI =<< lookup "id" dpath of 
    107107    Nothing  -> notFound . toResponse $ "Invalid number" 
    108108    Just pid -> do 
    109         mcontents <- query $ !LookupPost pid 
     109        mcontents <- query $ LookupPost pid 
    110110        case mcontents of 
    111111            Nothing -> notFound . toResponse $ "Post #" ++ show pid ++ " not found" 
    112112        ok . toResponse $ contents 
    113113 
    114 setBlogPost :: !DynamicPath -> !ServerPart Response 
     114setBlogPost :: DynamicPath -> ServerPart Response 
    115115setBlogPost dpath = case fromReqURI =<< lookup "id" dpath of 
    116116    Nothing -> notFound . toResponse $ "Invalid number" 
     
    120120            Nothing -> badRequest . toResponse $ "Bad input, couldn't find text" 
    121121            Just contents -> do 
    122                 update $ !SetPost pid contents 
     122                update $ SetPost pid contents 
    123123                ok . toResponse $ contents 
    124124}}}