All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.twitter.server.view.NotFoundView.scala Maven / Gradle / Ivy

There is a newer version: 18.9.1
Show newest version
package com.twitter.server.view

import com.twitter.finagle.http.{Request, Response, Status}
import com.twitter.finagle.{Service, SimpleFilter}
import com.twitter.io.Buf
import com.twitter.server.util.HttpUtils.{expectsHtml, newResponse}
import com.twitter.util.Future

object NotFoundView {
  private val NotFoundHtml: String =
    s"""
          
            404 · Twitter Server Admin
            
          
          
          
            

404 The page you requested could not be found.


Some endpoints are only available when the correct dependencies are added to your class path.
For more information, please see the twitter-server docs or return to /admin.
""" } class NotFoundView extends SimpleFilter[Request, Response] { import NotFoundView._ def apply(req: Request, svc: Service[Request, Response]) = if (!expectsHtml(req)) svc(req) else svc(req) flatMap { res => if (res.status != Status.NotFound) Future.value(res) else { newResponse( contentType = "text/html;charset=UTF-8", status = Status.NotFound, content = Buf.Utf8(NotFoundHtml) ) } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy