Working boilerplate.
This commit is contained in:
@@ -1,8 +1,36 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func spaHandler() http.HandlerFunc {
|
||||||
|
fs := getUIAssets()
|
||||||
|
fileServer := http.FileServer(http.FS(fs))
|
||||||
|
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.URL.Path == "/" {
|
||||||
|
fileServer.ServeHTTP(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
f, err := fs.Open(strings.TrimPrefix(path.Clean(r.URL.Path), "/"))
|
||||||
|
if err == nil {
|
||||||
|
defer f.Close()
|
||||||
|
}
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
r.URL.Path = "/"
|
||||||
|
}
|
||||||
|
fileServer.ServeHTTP(w, r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
frontend := getUIAssets()
|
|
||||||
fmt.Println(frontend)
|
log.Println("Starting glancr on port 8080")
|
||||||
|
http.HandleFunc("/", spaHandler())
|
||||||
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import HomeView from '../views/HomeView.vue'
|
import HomeView from '../views/HomeView.vue'
|
||||||
|
import NotFoundView from '../views/NotFoundView.vue'
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
@@ -17,6 +18,11 @@ const router = createRouter({
|
|||||||
// which is lazy-loaded when the route is visited.
|
// which is lazy-loaded when the route is visited.
|
||||||
component: () => import('../views/AboutView.vue'),
|
component: () => import('../views/AboutView.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/:catchAll(.*)",
|
||||||
|
name: 'not-found',
|
||||||
|
component: NotFoundView,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
8
ui/src/views/NotFoundView.vue
Normal file
8
ui/src/views/NotFoundView.vue
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<main>
|
||||||
|
<h1>Not Found</h1>
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
0
ui/vue.config.ts
Normal file
0
ui/vue.config.ts
Normal file
Reference in New Issue
Block a user