Commit d2d35f97 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Support multiple disjointed notes

Still needs to fix some hardcoded URLs. The problem with websockets is
that they use the first URL fragment to determine the documentId,
therefore we cannot proxy to `http://localhost:8009/notes/<frameId>`
because the underlying WS connection will use `noteId=notes`, which is
wrong.
parent 16bece62
...@@ -18,7 +18,7 @@ fi ...@@ -18,7 +18,7 @@ fi
# with the `sha256sum` result calculated on the `cabal.project` and # with the `sha256sum` result calculated on the `cabal.project` and
# `cabal.project.freeze`. This ensures the files stay deterministic so that CI # `cabal.project.freeze`. This ensures the files stay deterministic so that CI
# cache can kick in. # cache can kick in.
expected_cabal_project_hash="1059c049512dc2241d0b24e276206204ed007ba4b036719f3c397f2649801086" expected_cabal_project_hash="a05d90186f5c5d90cb6e806ffc38379af89a52d4289dd70def9e48ed8315fdd6"
expected_cabal_project_freeze_hash="3c64f68973846df84c31708abefcc95119eef58317a569d9a5940821b27b9d66" expected_cabal_project_freeze_hash="3c64f68973846df84c31708abefcc95119eef58317a569d9a5940821b27b9d66"
cabal --store-dir=$STORE_DIR v2-build --dry-run cabal --store-dir=$STORE_DIR v2-build --dry-run
......
...@@ -169,7 +169,7 @@ source-repository-package ...@@ -169,7 +169,7 @@ source-repository-package
source-repository-package source-repository-package
type: git type: git
location: https://github.com/adinapoli/http-reverse-proxy.git location: https://github.com/adinapoli/http-reverse-proxy.git
tag: 38c67da5c50972c6ff25be6aad5bb295d4badd3f tag: e746dfbe557ce131af1090e1c413fee16675c8e0
allow-older: * allow-older: *
allow-newer: * allow-newer: *
......
...@@ -97,7 +97,7 @@ mkNodeWithParent_ConfigureHyperdata _ _ _ _ = nodeError NotImplYet ...@@ -97,7 +97,7 @@ mkNodeWithParent_ConfigureHyperdata _ _ _ _ = nodeError NotImplYet
internalNotesProxy :: MicroServicesSettings -> T.Text internalNotesProxy :: MicroServicesSettings -> T.Text
internalNotesProxy MicroServicesSettings{..} = internalNotesProxy MicroServicesSettings{..} =
"http://localhost:" <> T.pack (show _msProxyPort) <> "/notes-proxy" "http://localhost:" <> T.pack (show _msProxyPort)
-- | Function not exposed -- | Function not exposed
mkNodeWithParent_ConfigureHyperdata' :: (HasNodeError err, HasDBid NodeType, HasSettings env) mkNodeWithParent_ConfigureHyperdata' :: (HasNodeError err, HasDBid NodeType, HasSettings env)
......
...@@ -54,7 +54,7 @@ renderProxyDestination ProxyDestination{..} ...@@ -54,7 +54,7 @@ renderProxyDestination ProxyDestination{..}
-- --
data ReverseProxyAPI mode = ReverseProxyAPI data ReverseProxyAPI mode = ReverseProxyAPI
{ notesProxy :: mode :- "notes-proxy" :> NamedRoutes NotesProxy { notesProxy :: mode :- NamedRoutes NotesProxy
, notesSocketIo :: mode :- "socket.io" :> NamedRoutes SocketIOProxy , notesSocketIo :: mode :- "socket.io" :> NamedRoutes SocketIOProxy
, meEndpoint :: mode :- "me" :> Raw , meEndpoint :: mode :- "me" :> Raw
} deriving Generic } deriving Generic
...@@ -94,7 +94,7 @@ socketIOProxyImplementation env = SocketIOProxy { ...@@ -94,7 +94,7 @@ socketIOProxyImplementation env = SocketIOProxy {
} }
notesProxyServer :: Env -> ServerT Raw m notesProxyServer :: Env -> ServerT Raw m
notesProxyServer env = defaultForwardServer (removeProxyPath "/notes-proxy") env notesProxyServer env = defaultForwardServer id env
slideProxyServer :: Env -> T.Text -> ServerT Raw m slideProxyServer :: Env -> T.Text -> ServerT Raw m
slideProxyServer env frameId = slideProxyServer env frameId =
...@@ -144,17 +144,11 @@ defaultForwardServer presendModifyRequest env = ...@@ -144,17 +144,11 @@ defaultForwardServer presendModifyRequest env =
proxyListeningPort = microSrvSettings ^. msProxyPort proxyListeningPort = microSrvSettings ^. msProxyPort
proxySettings :: ProxyDestination -> WaiProxySettings proxySettings :: ProxyDestination -> WaiProxySettings
proxySettings h@ProxyDestination{..} = proxySettings proxyDestination =
defaultWaiProxySettings { wpsProcessBody = \_req _res -> Just $ replaceRelativeLinks assetPath defaultWaiProxySettings {
, wpsModifyResponseHeaders = \_req _res -> tweakResponseHeaders wpsProcessBody = \_req _res -> Just $ replaceRelativeLinks ("http://localhost:8009")
} , wpsModifyResponseHeaders = \_req _res -> tweakResponseHeaders
where }
assetPath :: B.ByteString
assetPath
| fwdPort /= 80
= renderProxyDestination h
| otherwise
= fwdProto <> "//" <> fwdHost
newHost :: ProxyDestination -> RequestHeaders -> RequestHeaders newHost :: ProxyDestination -> RequestHeaders -> RequestHeaders
newHost hst hdrs = (hHost, renderProxyDestination hst) : filter ((/=) hHost . fst) hdrs newHost hst hdrs = (hHost, renderProxyDestination hst) : filter ((/=) hHost . fst) hdrs
...@@ -170,7 +164,7 @@ defaultForwardServer presendModifyRequest env = ...@@ -170,7 +164,7 @@ defaultForwardServer presendModifyRequest env =
let proxiedReq = presendModifyRequest $ originalRequest { let proxiedReq = presendModifyRequest $ originalRequest {
requestHeaders = (newReferer . newHost proxyDestination . noCache $ (requestHeaders originalRequest)) requestHeaders = (newReferer . newHost proxyDestination . noCache $ (requestHeaders originalRequest))
} }
pure $ WPRModifiedRequest proxiedReq ProxyDest (fwdHost proxyDestination) (fwdPort proxyDestination)) pure $ WPRModifiedRequest proxiedReq (ProxyDest (fwdHost proxyDestination) (fwdPort proxyDestination))
-- --
-- Utility functions -- Utility functions
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
git: "https://github.com/MercuryTechnologies/ekg-json.git" git: "https://github.com/MercuryTechnologies/ekg-json.git"
subdirs: subdirs:
- . - .
- commit: 38c67da5c50972c6ff25be6aad5bb295d4badd3f - commit: e746dfbe557ce131af1090e1c413fee16675c8e0
git: "https://github.com/adinapoli/http-reverse-proxy.git" git: "https://github.com/adinapoli/http-reverse-proxy.git"
subdirs: subdirs:
- . - .
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment