mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-04-04 01:48:18 +02:00
expose Router so servers can inject their own routes.
This commit is contained in:
parent
d9a6c6a1ad
commit
80e643c492
7
start.go
7
start.go
@ -19,7 +19,7 @@ type Settings struct {
|
||||
var s Settings
|
||||
var log = zerolog.New(os.Stderr).Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
||||
|
||||
var router = mux.NewRouter()
|
||||
var Router = mux.NewRouter()
|
||||
|
||||
func Start(relay Relay) {
|
||||
if err := envconfig.Process("", &s); err != nil {
|
||||
@ -32,7 +32,8 @@ func Start(relay Relay) {
|
||||
Log.Fatal().Err(err).Msg("failed to start")
|
||||
}
|
||||
|
||||
router.Path("/").Methods("GET").HandlerFunc(handleWebsocket(relay))
|
||||
Router.Path("/").Methods("GET").Headers("Upgrade", "websocket").
|
||||
HandlerFunc(handleWebsocket(relay))
|
||||
|
||||
if inj, ok := relay.(Injector); ok {
|
||||
go func() {
|
||||
@ -43,7 +44,7 @@ func Start(relay Relay) {
|
||||
}
|
||||
|
||||
srv := &http.Server{
|
||||
Handler: cors.Default().Handler(router),
|
||||
Handler: cors.Default().Handler(Router),
|
||||
Addr: s.Host + ":" + s.Port,
|
||||
WriteTimeout: 2 * time.Second,
|
||||
ReadTimeout: 2 * time.Second,
|
||||
|
Loading…
x
Reference in New Issue
Block a user