Fix embed Riot Web into Yggdrasil demo
parent
ddf1c8adf1
commit
3547a1768c
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package embed
|
package embed
|
||||||
|
|
||||||
func Embed(_ int, _ string) {
|
import "github.com/gorilla/mux"
|
||||||
|
|
||||||
|
func Embed(_ *mux.Router, _ int, _ string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,19 +7,20 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
"github.com/tidwall/sjson"
|
"github.com/tidwall/sjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
// From within the Riot Web directory:
|
// From within the Riot Web directory:
|
||||||
// go run github.com/mjibson/esc -o /path/to/dendrite/internal/embed/fs_riotweb.go -private -pkg embed .
|
// go run github.com/mjibson/esc -o /path/to/dendrite/internal/embed/fs_riotweb.go -private -pkg embed .
|
||||||
|
|
||||||
func Embed(listenPort int, serverName string) {
|
func Embed(rootMux *mux.Router, listenPort int, serverName string) {
|
||||||
url := fmt.Sprintf("http://localhost:%d", listenPort)
|
url := fmt.Sprintf("http://localhost:%d", listenPort)
|
||||||
embeddedFS := _escFS(false)
|
embeddedFS := _escFS(false)
|
||||||
embeddedServ := http.FileServer(embeddedFS)
|
embeddedServ := http.FileServer(embeddedFS)
|
||||||
|
|
||||||
http.DefaultServeMux.Handle("/", embeddedServ)
|
rootMux.Handle("/", embeddedServ)
|
||||||
http.DefaultServeMux.HandleFunc("/config.json", func(w http.ResponseWriter, _ *http.Request) {
|
rootMux.HandleFunc("/config.json", func(w http.ResponseWriter, _ *http.Request) {
|
||||||
configFile, err := embeddedFS.Open("/config.sample.json")
|
configFile, err := embeddedFS.Open("/config.sample.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
|
|
|
@ -154,7 +154,7 @@ func main() {
|
||||||
logrus.WithError(err).Panicf("failed to connect to public rooms db")
|
logrus.WithError(err).Panicf("failed to connect to public rooms db")
|
||||||
}
|
}
|
||||||
|
|
||||||
embed.Embed(*instancePort, "Yggdrasil Demo")
|
embed.Embed(base.BaseMux, *instancePort, "Yggdrasil Demo")
|
||||||
|
|
||||||
monolith := setup.Monolith{
|
monolith := setup.Monolith{
|
||||||
Config: base.Cfg,
|
Config: base.Cfg,
|
||||||
|
|
Loading…
Reference in New Issue