mirror of
https://github.com/jhillyerd/inbucket.git
synced 2026-01-08 20:21:55 +00:00
Add configurable base path for reverse proxy use (#169)
* ui: Refactor routing functions into Router record * ui: Store base URI in AppConfig * ui: Use basePath in Router functions * backend: Add Web.BasePath config option and update routes * Tweaks to get SPA to bootstrap basePath configured * ui: basePath support for apis/serve * ui: basePath support for message monitor * web: Redirect requests to / when basePath configured * doc: add basepath to config.md * Closes #107
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
module Page.Monitor exposing (Model, Msg, init, update, view)
|
||||
|
||||
import Api
|
||||
import Browser.Navigation as Nav
|
||||
import Data.MessageHeader as MessageHeader exposing (MessageHeader)
|
||||
import Data.Session as Session exposing (Session)
|
||||
import DateFormat as DF
|
||||
@@ -21,7 +23,7 @@ import Html
|
||||
, thead
|
||||
, tr
|
||||
)
|
||||
import Html.Attributes exposing (class, tabindex)
|
||||
import Html.Attributes exposing (class, src, tabindex)
|
||||
import Html.Events as Events
|
||||
import Json.Decode as D
|
||||
import Route
|
||||
@@ -101,7 +103,9 @@ update msg model =
|
||||
openMessage : MessageHeader -> Model -> ( Model, Cmd Msg )
|
||||
openMessage header model =
|
||||
( model
|
||||
, Route.pushUrl model.session.key (Route.Message header.mailbox header.id)
|
||||
, Route.Message header.mailbox header.id
|
||||
|> model.session.router.toPath
|
||||
|> Nav.replaceUrl model.session.key
|
||||
)
|
||||
|
||||
|
||||
@@ -132,8 +136,12 @@ view model =
|
||||
[ button [ Events.onClick Clear ] [ text "Clear" ]
|
||||
]
|
||||
]
|
||||
|
||||
-- monitor-messages maintains a websocket connection to the Inbucket daemon at the path
|
||||
-- specified by `src`.
|
||||
, node "monitor-messages"
|
||||
[ Events.on "connected" (D.map Connected <| D.at [ "detail" ] <| D.bool)
|
||||
[ src (Api.monitorUri model.session)
|
||||
, Events.on "connected" (D.map Connected <| D.at [ "detail" ] <| D.bool)
|
||||
, Events.on "message" (D.map MessageReceived D.value)
|
||||
]
|
||||
[]
|
||||
|
||||
Reference in New Issue
Block a user