packages feed

micro-gateway 1.1.0.0 → 1.1.0.1

raw patch · 4 files changed

+19/−8 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Micro.Gateway.Types: [denyPages] :: App -> [Text]
- Micro.Gateway.Types: App :: AppKey -> AppSecret -> Bool -> Bool -> Bool -> ((Request -> Manager -> IO (Response ByteString)) -> String -> IO (Response ByteString)) -> (Maybe String -> Request -> IO (Either String ())) -> (Int64 -> Int -> IO ()) -> IO () -> Int -> Maybe String -> ((String -> Int -> IO ()) -> IO ()) -> [Text] -> ByteString -> [Text] -> App
+ Micro.Gateway.Types: App :: AppKey -> AppSecret -> Bool -> Bool -> Bool -> ((Request -> Manager -> IO (Response ByteString)) -> String -> IO (Response ByteString)) -> (Maybe String -> Request -> IO (Either String ())) -> (Int64 -> Int -> IO ()) -> IO () -> Int -> Maybe String -> ((String -> Int -> IO ()) -> IO ()) -> [Text] -> ByteString -> [Text] -> [Text] -> App

Files

app/Main.hs view
@@ -60,6 +60,8 @@    -- allow page prefix   , allowPages   :: [LT.Text]+  -- deny page prefix+  , denyPages    :: [LT.Text]   }  data Config = Config@@ -81,6 +83,7 @@     proxy        <- o .:? "proxy"        .!= False     wsUrl        <- o .:? "wsUrl"     allowPages   <- o .:? "allowPages"   .!= []+    denyPages    <- o .:? "denyPages"    .!= []     replacePages <- o .:? "replacePages" .!= []     rname        <- o .:? "replaceName"  .!= "__KEY__"     return AppConfig@@ -141,6 +144,7 @@             { GW.doRequest        = processRequest mgr baseUrl             , GW.prepareWsRequest = processWsRequest $ fromMaybe baseUrl wsUrl             , GW.allowPages       = allowPages+            , GW.denyPages        = denyPages             , GW.replaceKeyName   = replaceName             , GW.replaceKeyPages  = replacePages             }
micro-gateway.cabal view
@@ -1,5 +1,5 @@ name:                micro-gateway-version:             1.1.0.0+version:             1.1.0.1 synopsis:            A Micro service gateway. description:         A Micro service gateway. Support http, and websockets reverse proxy. homepage:            https://github.com/Lupino/micro-gateway#readme
src/Micro/Gateway.hs view
@@ -264,15 +264,19 @@ verifySignature' proxy app@App{isSecure=False} = proxy app verifySignature' proxy app@App{isSecure=True}  = do   sp <- getPathName app-  if isAllowPages (allowPages app) sp-    then proxy app else verifySignature proxy app+  if isInPages (allowPages app) sp+    then+    if isInPages (denyPages app) sp+      then verifySignature proxy app+      else proxy app+    else verifySignature proxy app -  where isAllowPages :: [LT.Text] -> LT.Text -> Bool-        isAllowPages [] _ = False-        isAllowPages (x:xs) p+  where isInPages :: [LT.Text] -> LT.Text -> Bool+        isInPages [] _ = False+        isInPages (x:xs) p           | x == p = True           | x == LT.take (LT.length x) p = True-          | otherwise = isAllowPages xs p+          | otherwise = isInPages xs p  verifySignature :: (App -> ActionM ()) -> App -> ActionM () verifySignature proxy app@App{onlyProxy = True} = proxy app
src/Micro/Gateway/Types.hs view
@@ -85,8 +85,10 @@   , replaceKeyPages :: [LT.Text]   , replaceKeyName :: ByteString -  -- allow page prefix+  -- allow page prefix only effect get pages   , allowPages :: [LT.Text]+  -- deny page prefix only effect allow pages+  , denyPages :: [LT.Text]   }  @@ -103,6 +105,7 @@   , replaceKeyPages = []   , replaceKeyName = "__KEY__"   , allowPages = []+  , denyPages = []   , ..   }