mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
local default URI for client.
This commit is contained in:
parent
aace4add5b
commit
085806d1b2
@ -11,6 +11,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
publicPath: './',
|
||||||
configureWebpack: {
|
configureWebpack: {
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"n.eko.moe/neko/internal/http/endpoint"
|
|
||||||
"n.eko.moe/neko/internal/http/middleware"
|
"n.eko.moe/neko/internal/http/middleware"
|
||||||
"n.eko.moe/neko/internal/types"
|
"n.eko.moe/neko/internal/types"
|
||||||
"n.eko.moe/neko/internal/types/config"
|
"n.eko.moe/neko/internal/types/config"
|
||||||
@ -37,20 +36,14 @@ func New(conf *config.Server, webSocketHandler types.WebSocketHandler) *Server {
|
|||||||
|
|
||||||
fs := http.FileServer(http.Dir(conf.Static))
|
fs := http.FileServer(http.Dir(conf.Static))
|
||||||
router.Get("/*", func(w http.ResponseWriter, r *http.Request) {
|
router.Get("/*", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if _, err := os.Stat(conf.Static + r.RequestURI); os.IsNotExist(err) {
|
if _, err := os.Stat(conf.Static + r.RequestURI); !os.IsNotExist(err) {
|
||||||
http.StripPrefix(r.RequestURI, fs).ServeHTTP(w, r)
|
|
||||||
} else {
|
|
||||||
fs.ServeHTTP(w, r)
|
fs.ServeHTTP(w, r)
|
||||||
|
} else {
|
||||||
|
w.WriteHeader(http.StatusNotFound)
|
||||||
|
fmt.Fprint(w, "404 page not found")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
router.NotFound(endpoint.Handle(func(w http.ResponseWriter, r *http.Request) error {
|
|
||||||
return &endpoint.HandlerError{
|
|
||||||
Status: http.StatusNotFound,
|
|
||||||
Message: fmt.Sprintf("file '%s' is not found", r.RequestURI),
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
|
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: conf.Bind,
|
Addr: conf.Bind,
|
||||||
Handler: router,
|
Handler: router,
|
||||||
|
Loading…
Reference in New Issue
Block a user