src/Pure/General/http.scala
changeset 75109 e6162afc5460
parent 75108 05ba781cf890
child 75110 3c8f24e9eff1
equal deleted inserted replaced
75108:05ba781cf890 75109:e6162afc5460
   181   {
   181   {
   182     def home: String = url_path(server, service)
   182     def home: String = url_path(server, service)
   183     def root: String = home + "/"
   183     def root: String = home + "/"
   184     def query: String = home + "?"
   184     def query: String = home + "?"
   185 
   185 
   186     def uri_name: String = uri.toString
   186     def toplevel: Boolean = uri_name == home || uri_name == root
       
   187 
       
   188     val uri_name: String = uri.toString
   187 
   189 
   188     def uri_path: Option[Path] =
   190     def uri_path: Option[Path] =
   189       for {
   191       for {
   190         s1 <- Option(uri.getPath)
   192         s1 <- Option(uri.getPath)
   191         s2 <- Library.try_unprefix(root, s1)
   193         s2 <- Library.try_unprefix(root, s1)
   313 
   315 
   314   /* welcome */
   316   /* welcome */
   315 
   317 
   316   def welcome(name: String = "welcome"): Service =
   318   def welcome(name: String = "welcome"): Service =
   317     Service.get(name, request =>
   319     Service.get(name, request =>
   318       if (request.uri_name == request.home) {
   320       {
   319         Some(Response.text("Welcome to " + Isabelle_System.identification()))
   321         if (request.toplevel) {
   320       }
   322           Some(Response.text("Welcome to " + Isabelle_System.identification()))
   321       else None)
   323         }
       
   324         else None
       
   325       })
   322 
   326 
   323 
   327 
   324   /* fonts */
   328   /* fonts */
   325 
   329 
   326   private lazy val html_fonts: List[Isabelle_Fonts.Entry] =
   330   private lazy val html_fonts: List[Isabelle_Fonts.Entry] =
   327     Isabelle_Fonts.fonts(hidden = true)
   331     Isabelle_Fonts.fonts(hidden = true)
   328 
   332 
   329   def fonts(name: String = "fonts"): Service =
   333   def fonts(name: String = "fonts"): Service =
   330     Service.get(name, request =>
   334     Service.get(name, request =>
   331       {
   335       {
   332         if (request.uri_name == request.home) {
   336         if (request.toplevel) {
   333           Some(Response.text(cat_lines(html_fonts.map(entry => entry.path.file_name))))
   337           Some(Response.text(cat_lines(html_fonts.map(entry => entry.path.file_name))))
   334         }
   338         }
   335         else {
   339         else {
   336           request.uri_path.flatMap(path =>
   340           request.uri_path.flatMap(path =>
   337             html_fonts.collectFirst(
   341             html_fonts.collectFirst(