metar-http 0.0.1 → 0.0.2
raw patch · 3 files changed
+22/−6 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- changelog.md +4/−0
- metar-http.cabal +1/−1
- src/Data/Aviation/Metar/Http.hs +17/−5
changelog.md view
@@ -1,3 +1,7 @@+0.0.2++* allow .../* request for all on one line+ 0.0.1 * Initial release
metar-http.cabal view
@@ -1,5 +1,5 @@ name: metar-http-version: 0.0.1+version: 0.0.2 license: BSD3 license-file: LICENCE author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@sıɹɹoɯʇ>
src/Data/Aviation/Metar/Http.hs view
@@ -15,9 +15,8 @@ import Data.Function(($)) import Data.List(intercalate, take) import Data.Maybe(Maybe(Nothing, Just), listToMaybe)-import Text.Read(reads)+import Data.String(String) import Data.Semigroup((<>))-import Text.Show(show) import Data.Text(unpack, toLower) import Data.Tuple(fst) import Network.HTTP.Types.Header(hContentType)@@ -26,12 +25,21 @@ import Network.Wai.Handler.Warp(setPort, runSettings, defaultSettings) import System.Environment(getArgs) import System.IO(IO)+import Text.Read(Read, reads)+import Text.Show(show) +readMaybe ::+ Read a =>+ String+ -> Maybe a+readMaybe n =+ fst <$> listToMaybe (reads n)+ metarHTTPapp :: Application metarHTTPapp req withResp = let msg =- "path /metar/<icao> or /metar/<icao>/<nlines> or /taf/<icao> or /taf/<icao>/<nlines>"+ "path /metar/<icao> OR /metar/<icao>/<nlines> OR /taf/<icao> OR /taf/<icao>/<nlines> OR /metar/<icao>/* OR /taf/<icao>/*" _404 = responseLBS status404@@ -43,8 +51,12 @@ unpack xxxx tk r' = case unpack <$> r' of+ "":_ ->+ Just id+ "*":_ ->+ Just (\k -> [intercalate " " k]) n:_ ->- take . fst <$> listToMaybe (reads n)+ take <$> readMaybe n [] -> Just id mt =@@ -98,7 +110,7 @@ [] -> id (q:_) ->- case fst <$> listToMaybe (reads q) of+ case readMaybe q of Nothing -> id Just n ->