<commit_before>﻿// ----------------------------------------------------------------------------
// (c) <NAME>, 2013
//
// This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
// copy of the license can be found in the License.txt file at the root of this distribution. 
// By using this source code in any fashion, you are agreeing to be bound 
// by the terms of the Apache License, Version 2.0.
//
// You must not remove this notice, or any other, from this software.
// ----------------------------------------------------------------------------
namespace FlexSearch.Core

open Autofac
open FlexSearch.Api
open FlexSearch.Api.Message
open FlexSearch.Core
open FlexSearch.Utility
open Microsoft.Owin
open Microsoft.Owin.Hosting
open Newtonsoft.Json
open Owin
open System
open System.Collections.Concurrent
open System.Collections.Generic
open System.ComponentModel.Composition
open System.IO
open System.Linq
open System.Net
open System.Threading
open System.Threading.Tasks

/// <summary>
/// Thrift server
/// </summary>
[<Name("Http")>]
[<Sealed>]
type OwinServer(indexService : IIndexService, httpFactory : IFlexFactory<IHttpHandler>, ?port0 : int) = 
    let port = defaultArg port0 9800
    let httpModule = httpFactory.GetAllModules()
    
    /// <summary>
    /// Default OWIN method to process request
    /// </summary>
    /// <param name="owin">OWIN Context</param>
    let exec (owin : IOwinContext) = 
        async { <commit_msg>Take more than one verb for a single handler<commit_after>﻿// ----------------------------------------------------------------------------
// (c) <NAME>, 2013
//
// This source code is subject to terms and conditions of the Apache License, Version 2.0. A 
// copy of the license can be found in the License.txt file at the root of this distribution. 
// By using this source code in any fashion, you are agreeing to be bound 
// by the terms of the Apache License, Version 2.0.
//
// You must not remove this notice, or any other, from this software.
// ----------------------------------------------------------------------------
namespace FlexSearch.Core

open Autofac
open FlexSearch.Api
open FlexSearch.Api.Message
open FlexSearch.Core
open FlexSearch.Utility
open Microsoft.Owin
open Microsoft.Owin.Hosting
open Newtonsoft.Json
open Owin
open System
open System.Collections.Concurrent
open System.Collections.Generic
open System.ComponentModel.Composition
open System.IO
open System.Linq
open System.Net
open System.Threading
open System.Threading.Tasks

/// <summary>
/// Thrift server
/// </summary>
[<Name("Http")>]
[<Sealed>]
type OwinServer(indexService : IIndexService, httpFactory : IFlexFactory<IHttpHandler>, ?port0 : int) = 
    let port = defaultArg port0 9800
    let httpModule = 
        let modules = httpFactory.GetAllModules()
        let result = new Dictionary<string, IHttpHandler>(StringComparer.OrdinalIgnoreCase)
        for m in modules do
            // check if the key supports more than one http verb
            if m.Key.Contains("|") then
                let verb = m.Key.Substring(0, m.Key.IndexOf("-"))
                let verbs = verb.Split([|'|'|], StringSplitOptions.RemoveEmptyEntries)
                let value = m.Key.Substring(m.Key.IndexOf("-") + 1)
                for v in verbs do
                    result.Add(v + "-" + value, m.Value)
            else
                result.Add(m.Key, m.Value)
        result

    /// <summary>
    /// Default OWIN method to process request
    /// </summary>
    /// <param name="owin">OWIN Context</param>
    let exec (owin : IOwinContext) = 
        async { 
{'fraction_non_alphanumeric': 0.17776554760594387, 'fraction_numerical': 0.00825536598789213, 'mean_word_length': 2.1553819444444446, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1991371', 'n_tokens_mistral': 987, 'n_tokens_neox': 955, 'n_words': 351}