currently i’m piecing the URL together from the Session argument as follows, but it’d be nice if there were an exported public way to do this. or did i miss it?
App() do session::Session
server = session.connection.connection.server
DOM.div(string(server.protocol, server.url, ':', server.port, server.routes.table[1].first))
end
[EDIT: updated code to actually work]
What do you want to do exactly?
There are multiple ways to get the servers public url.
i want to do exactly that-- programmatically get the servers public URL, so i can either display it on the page or better yet copy it to the clipboard on a button press. thx!
I guess you can use:
using Bonito
get_server(session::Session) = get_server(session.asset_server)
get_server(server::HTTPAssetServer) = server.server
get_server(server::Bonito.ChildAssetServer) = get_server(server.parent)
get_server(any) = error("Not an HTTP server for session")
App() do session::Session
server = get_server(session)
DOM.div(string(Bonito.online_url(server, "")))
end
Would be cool if this works:
App() do session::Session
DOM.div(Bonito.Link("/"))
end
This doesn’t work right now, but I think that could fall under the use cases for Link
.
thanks! those new get_server
definitions would be handy to have in Bonito. and i guess i misunderstood the docstring for online_url
– i interpreted that as setting the URL, not getting it.