/// <summary> /// Try to build a <see cref="T:Server.Routing.AutoRoute"/> /// </summary> /// <returns>The auto route.</returns> /// <param name="url">URL.</param> private AutoRoute GetAutoRoute(String url) { if (url.EndsWith(".js", StringComparison.CurrentCulture) && this.autoRouteJS) { return(AutoRoute.GenrateAutoRoute(url)); } if (url.EndsWith(".css", StringComparison.CurrentCulture) && this.autoRouteCSS) { return(AutoRoute.GenrateAutoRoute(url)); } if (url.EndsWith(".html", StringComparison.CurrentCulture) && this.autoRouteHTML) { return(AutoRoute.GenrateAutoRoute(url)); } return(null); }
/// <summary> /// Genrates the auto route. /// </summary> /// <returns>The auto route.</returns> /// <param name="url">URL.</param> public static AutoRoute GenrateAutoRoute(String url) { AutoRoute route = null; String path = url; // cut leading '/' if (url.StartsWith("/", StringComparison.CurrentCulture)) { path = path.Remove(0, 1); } try { route = new AutoRoute(url, path); } catch (IOException e) { Console.WriteLine(e.Message); route = null; } return(route); }