alpmestan / servant

Moved to http://github.com/haskell-servant
50 stars 1 forks source link

More query params #22

Closed alpmestan closed 10 years ago

alpmestan commented 10 years ago

This addresses #19 and also adds a QueryFlag param for value-less GET parameters. Comes with server, client & docs support, along with some tests.

soenkehahn commented 10 years ago

LGTM, please merge.

alpmestan commented 10 years ago

Yeah, maybe we'll have to extend a bit the flag thing to make it accept true/false. Sounds reasonable. I'm merging this PR and we can add that later.

soenkehahn commented 10 years ago

Very good, thanks.

alpmestan commented 10 years ago

Alright, I took another stab at this, to extend QueryFlag.

What do you think about:

        param = case lookup paramname querytext of
          Just Nothing  -> True  -- param is there, with no value
          Just (Just v) -> examine v -- param with a value
          Nothing       -> False -- param not in the query string

    where examine v | v == "true" || v == "1" || v == "" = True
                    | otherwise = False
soenkehahn commented 10 years ago

Yes, I like it.

alpmestan commented 10 years ago

Ok, I'll push a patch for that along with an additional test on new-impl.