in server/src/main/scala/com/twitter/server/handler/ServerRegistryHandler.scala [81:114]
def apply(req: Request): Future[Response] = {
val uri = Uri.fromRequest(req)
uri.path.stripPrefix(uriPrefix) match {
case idx @ ("index.html" | "index.htm" | "index.txt" | "servers") =>
val servers = (registry.registrants.flatMap {
case e: StackRegistry.Entry if e.name.nonEmpty =>
for (scope <- findScope(e.name)) yield (scope, e)
case _ => Nil
}).toSeq
val html = ServerRegistryHandler.render(servers)
// This is useful to avoid the returned fragment being wrapped
// with an index in the context of an ajax call.
val typ = if (idx.endsWith(".txt")) "text/plain" else "text/html"
newResponse(
contentType = s"$typ;charset=UTF-8",
content = Buf.Utf8(html)
)
case name =>
val decodedName = URLDecoder.decode(name, StandardCharsets.UTF_8.name)
val entries = registry.registrants filter { _.name == decodedName }
if (entries.isEmpty) new404(s"$name could not be found.")
else {
val server = entries.head
val scope = findScope(server.name)
val html = StackRegistryView.render(server, scope)
newResponse(
contentType = "text/html;charset=UTF-8",
content = Buf.Utf8(html)
)
}
}
}