func HandleDirectoryLookups() func(*Server) {
	return func(s *Server) {
		if s.directoryHandlerSetup {
			return
		}
		s.directoryHandlerSetup = true
		s.mux.Handle("/_matrix/federation/v1/query/directory", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
			alias := req.URL.Query().Get("room_alias")
			if roomID, ok := s.aliases[alias]; ok {
				b, err := json.Marshal(gomatrixserverlib.RespDirectory{
					RoomID: roomID,
					Servers: []gomatrixserverlib.ServerName{
						gomatrixserverlib.ServerName(s.ServerName),
					},
				})
				if err != nil {
					w.WriteHeader(500)
					w.Write([]byte("complement: HandleDirectoryLookups failed to marshal JSON: " + err.Error()))
					return
				}
				w.WriteHeader(200)
				w.Write(b)
				return
			}
			w.WriteHeader(404)
			w.Write([]byte(`{
				"errcode": "M_NOT_FOUND",
				"error": "Room alias not found."
			}`))
		})).Methods("GET")
	}
}
// HandleDirectoryLookups will automatically return room IDs for any aliases present on this server.
HandleDirectoryLookups will automatically return room IDs for any aliases present on this server.
// HandleDirectoryLookups will automatically return room IDs for any aliases present on this server .
func HandleDirectoryLookups() func(*Server) {
	return func(s *Server) {
		if s.directoryHandlerSetup {
			return
		}
		s.directoryHandlerSetup = true
		s.mux.Handle("/_matrix/federation/v1/query/directory", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
			alias := req.URL.Query().Get("room_alias")
			if roomID, ok := s.aliases[alias]; ok {
				b, err := json.Marshal(gomatrixserverlib.RespDirectory{
					RoomID: roomID,
					Servers: []gomatrixserverlib.ServerName{
						gomatrixserverlib.ServerName(s.ServerName),
					},
				})
				if err != nil {
					w.WriteHeader(500)
					w.Write([]byte("complement: HandleDirectoryLookups failed to marshal JSON: " + err.Error()))
					return
				}
				w.WriteHeader(200)
				w.Write(b)
				return
			}
			w.WriteHeader(404)
			w.Write([]byte(`{
				"errcode": "M_NOT_FOUND",
				"error": "Room alias not found."
			}`))
		})).Methods("GET")
	}
}
func HandleDirectoryLookups ( ) func ( * Server ) { return func ( s * Server ) { if s . directoryHandlerSetup { return } s . directoryHandlerSetup = true s . mux . Handle ( " " , http . HandlerFunc ( func ( w http . ResponseWriter , req * http . Request ) { alias := req . URL . Query ( ) . Get ( " " ) if roomID , ok := s . aliases [ alias ] ; ok { b , err := json . Marshal ( gomatrixserverlib . RespDirectory { RoomID : roomID , Servers : [ ] gomatrixserverlib . ServerName { gomatrixserverlib . ServerName ( s . ServerName ) , } , } ) if err != nil { w . WriteHeader ( 500 ) w . Write ( [ ] byte ( " " + err . Error ( ) ) ) return } w . WriteHeader ( 200 ) w . Write ( b ) return } w . WriteHeader ( 404 ) w . Write ( [ ] byte ( `{
				"errcode": "M_NOT_FOUND",
				"error": "Room alias not found."
			}` ) ) } ) ) . Methods ( " " ) } }
HandleDirectoryLookups will automatically return room IDs for any aliases present on this server.
HandleDirectoryLookups will automatically return room IDs for any aliases present on this server .