mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-11-18 10:07:44 +01:00
fix(all): use v2 module
This commit is contained in:
committed by
fiatjaf_
parent
523b11d068
commit
2771d9b8ba
14
start.go
14
start.go
@@ -42,16 +42,22 @@ type Server struct {
|
||||
|
||||
// in case you call Server.Start
|
||||
Addr string
|
||||
serveMux *http.ServeMux
|
||||
httpServer *http.Server
|
||||
}
|
||||
|
||||
func (s *Server) Router() *http.ServeMux {
|
||||
return s.serveMux
|
||||
}
|
||||
|
||||
// NewServer initializes the relay and its storage using their respective Init methods,
|
||||
// returning any non-nil errors, and returns a Server ready to listen for HTTP requests.
|
||||
func NewServer(relay Relay) (*Server, error) {
|
||||
srv := &Server{
|
||||
Log: defaultLogger(relay.Name() + ": "),
|
||||
relay: relay,
|
||||
clients: make(map[*websocket.Conn]struct{}),
|
||||
Log: defaultLogger(relay.Name() + ": "),
|
||||
relay: relay,
|
||||
clients: make(map[*websocket.Conn]struct{}),
|
||||
serveMux: &http.ServeMux{},
|
||||
}
|
||||
|
||||
// init the relay
|
||||
@@ -80,6 +86,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
s.HandleWebsocket(w, r)
|
||||
} else if r.Header.Get("Accept") == "application/nostr+json" {
|
||||
s.HandleNIP11(w, r)
|
||||
} else {
|
||||
s.serveMux.ServeHTTP(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user