Skip to content

Commit e91db2e

Browse files
committed
sub routing bits
1 parent 8d95915 commit e91db2e

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

backend/internal/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (server *Server) Run() error {
132132

133133
// TODO: Move the compiler routes to a separate file/into compiler
134134
// Apps
135-
server.router.GET("/api/app-resources/:id/base.html", func(res http.ResponseWriter, req *http.Request, params httprouter.Params) {
135+
server.router.GET("/api/app-resources/:id/base/*filepath", func(res http.ResponseWriter, req *http.Request, params httprouter.Params) {
136136
id := params.ByName("id")
137137
res.Header().Set("Content-Type", "text/html; charset=utf-8")
138138

backend/robin.servers.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
22
"devServers": {
3-
"cli": "go run github.com/mitranim/gow -e 'go,tsx,html' run ./cmd/cli start"
3+
"cli": {
4+
"healthChecks": [
5+
{
6+
"type": "tcp",
7+
"port": 9010
8+
}
9+
],
10+
"command": "go run github.com/mitranim/gow -e 'go,tsx,html' run ./cmd/cli start"
11+
}
412
}
513
}

frontend/components/AppWindow.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ function AppWindowContent({ id, setTitle }: AppWindowProps) {
5959

6060
const iframeRef = React.useRef<HTMLIFrameElement | null>(null);
6161
const [error, setError] = React.useState<string | null>(null);
62+
const subRoute = React.useMemo(
63+
() =>
64+
router.isReady
65+
? router.asPath.substring('/app/'.length + id.length)
66+
: null,
67+
[router.isReady, router.asPath, id],
68+
);
6269

6370
React.useEffect(() => {
6471
const onMessage = (message: MessageEvent) => {
@@ -143,7 +150,7 @@ function AppWindowContent({ id, setTitle }: AppWindowProps) {
143150

144151
<iframe
145152
ref={iframeRef}
146-
src={`http://localhost:9010/api/app-resources/${id}/base.html`}
153+
src={`http://localhost:9010/api/app-resources/${id}/base${subRoute}`}
147154
style={{ border: '0', flexGrow: 1, width: '100%', height: '100%' }}
148155
/>
149156
</>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './index';

0 commit comments

Comments
 (0)