Edit

kc3-lang/kc3/test/httpd/config/routes.kc3

Branch :

  • test/httpd/config/routes.kc3
  • def HTTPd.routes = []
    
    def_route("/", DocController.route)
    
    # def_route("/fx/", FXController.fx_route)
    # def_route("/tags/", FXController.tags_route)
    # def_route("/properties/", FXController.properties_route)
    # def_static_route("/file", "./fx/", 1)
    
    def_route("/sitemap.xml", SitemapController.route)
    
    def_route("/system", SystemController.route)
    
    def_route("/", PageController.route)
    
    HTTPd.Route.def_static_route("", "./static/", 0)
    
    defmodule Route do
    
      def doc = fn (path, locale) {
        if List.has?(Config.available_locales, locale) do
          "/#{URL.escape(locale)}#{URL.escape(path)}"
        else
          URL.escape(path)
        end
      }
    
      def locale = fn (url, url_locale, locale) {
        if Str.starts_with?(url, "/#{url_locale}") do
          url = Str.slice(url, Str.size(url_locale) + 1, -1)
        end
        if List.has?(Config.available_locales, locale) do
          "/#{URL.escape(locale)}#{URL.escape(url)}"
        else
          URL.escape(url)
        end
      }
    
    end