internal ServerContext(ServerContextSharedState sharedState, Match regexMatch) { this.sharedState = sharedState; this.regexMatch = regexMatch; }
private void ProcessRequest(object threadContext) { var context = (HttpListenerContext)threadContext; var request = context.Request; var response = context.Response; // Set default encoding: response.ContentEncoding = System.Text.Encoding.UTF8; var urlWithoutQuery = request.RawUrl; var queryPos = urlWithoutQuery.IndexOf('?'); if (queryPos != -1) { urlWithoutQuery = urlWithoutQuery.Substring(0, queryPos); } var sharedState = new ServerContextSharedState(context); foreach (var tup in routes) { Match match; if (tup.Item1 == null) { match = null; } else { match = tup.Item1.Match(urlWithoutQuery); } if (match == null || match.Success) { if (tup.Item2(new ServerContext(sharedState, match))) { return; } } } DefaultErrorProcessor(context); }