func (e *Executor) handleShowNamespace(w *common.ResponseWriter, stmt skl.Statement) { _, ok := stmt.(*skl.ShowNamespacesStatement) if !ok { w.Fail(common.InvalidStatementType, "expected *ShowNamespacesStatement, got %s instead", reflect.TypeOf(stmt)) return } // Get session user user := e.session.user if user.IsAdmin() { // Get namespace store namespaceStore, err := e.system.Namespaces() if err != nil { w.Fail(common.InternalServerError, "could not access namespace data") return } // Stream namespaces w.Write(w.Colors.LightYellow) namespaces := namespaceStore.Stream() for name := range namespaces { w.Write([]byte(" " + name + "\r\n")) } w.Write(w.Colors.Reset) } else { // List namespaces w.Write(w.Colors.Yellow) for _, name := range user.Namespaces() { w.Write([]byte(" " + name + "\r\n")) } w.Write(w.Colors.Reset) } w.Success(common.OK, "") }