<commit_before>package service

import (
    "bloom"
    "fmt"
    "net/http"
    "log"
)

var filter bloom.Filter = bloom.New(100,0.01)

func add(w http.ResponseWriter, r *http.Request) {
    key := r.URL.Path[len("/add/"):]

    filter.Add([]byte(key));

    w.WriteHeader(http.StatusCreated)
    fmt.Fprintf(w, "/contains/%s", key)
}

func contains(w http.ResponseWriter, r *http.Request) {
    key := r.URL.Path[len("/contains/"):]

    if (filter.Contains([]byte(key))) {
        w.WriteHeader(http.StatusOK)

        return
    }

    w.WriteHeader(http.StatusNotFound)
}

func ListenAndServe(address string) {
    http.HandleFunc("/add/", add)
    http.HandleFunc("/contains/", contains)
    log.Print("Server starting on ", address)
    http.ListenAndServe(address, nil)
}
<commit_msg>Defining the service API<commit_after>package service

import (
    "bloom"
    "fmt"
    "net/http"
    "log"
    "github.com/gorilla/mux"
)

var filter bloom.Filter = bloom.New(100,0.01)

func add(w http.ResponseWriter, r *http.Request) {
    key := r.URL.Path[len("/add/"):]

    filter.Add([]byte(key));

    w.WriteHeader(http.StatusCreated)
    fmt.Fprintf(w, "/contains/%s", key)
}

func contains(w http.ResponseWriter, r *http.Request) {
    key := r.URL.Path[len("/contains/"):]

    if (filter.Contains([]byte(key))) {
        w.WriteHeader(http.StatusOK)

        return
    }

    w.WriteHeader(http.StatusNotFound)
}

func createFilter(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "createFilter%+v\n", mux.Vars(r))
}

func retrieveFilter(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "retrieveFilter %+v\n", mux.Vars(r))
}

func deleteFilter(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "deleteFilter %+v\n", mux.Vars(r))
}

func createEntry(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "createEntry %+v\n", mux.Vars(r))
}

func retrieveEntry(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "retrieveEntry %+v\n", mux.Vars(r))
}

func ListenAndServe(address string) {
    r := mux.NewRouter()
    s := r.PathPrefix("/v1/filters").Subrouter()

    s.HandleFunc("", createFilter).Methods("POST")
    s.HandleFunc("/{filterName}", retrieveFilter).Methods("GET")
    s.HandleFunc("/{filterName}", deleteFilter).Methods("DELETE")
    s.HandleFunc("/{filterName}/entries", createEntry).Methods("POST")
    s.HandleFunc("/{filterName}/entries/{entryName}", retrieveEntry).Methods("GET")

    http.Handle("/", r)
    log.Print("Server starting on ", address)
    http.ListenAndServe(address, nil)
}

{'fraction_non_alphanumeric': 0.17800233190827827, 'fraction_numerical': 0.005052467936261173, 'mean_word_length': 3.697080291970803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2935751', 'n_tokens_mistral': 925, 'n_tokens_neox': 907, 'n_words': 156}