<commit_before>package main

import (
	"flag"
	"fmt"
	"log"
	"net/http"

	"github.com/globocom/config"
	"github.com/gorilla/mux"

	"github.com/wiliamsouza/apollo/api"
	"github.com/wiliamsouza/apollo/db"
)

const version = "0.0.1"

func main() {
	configFile := flag.String("config", "/etc/apollo.conf", "Apollo webserver configuration file")
	gVersion := flag.Bool("version", false, "Print version and exit")

	flag.Parse()

	if *gVersion {
		fmt.Printf("apollo-webserver version %s\n", version)
		return
	}
	err := config.ReadAndWatchConfigFile(*configFile)
	if err != nil {
		msg := `Could not find apollo config file. Searched on %s. For an example conf check /etc/apollo.conf file.\n %s`
		log.Panicf(msg, *configFile, err)
	}

	db.Connect()

	r := mux.NewRouter()
	r.HandleFunc("/tests/packages", api.ListPackages).Methods("GET")
	r.HandleFunc("/tests/packages", api.UploadPackage).Methods("POST")
	r.HandleFunc("/tests/packages/{filename}", api.DetailPackage).Methods("GET")
	r.HandleFunc("/tests/packages/downloads/{filename}", api.DownloadPackage).Methods("GET")
	r.HandleFunc("/users", api.NewUser).Methods("POST")
	http.Handle("/", r)

	bind, err := config.GetString("webserver:bind")
	if err != nil {
		panic(err)
	}

	err = http.ListenAndServe(bind, nil)
	if err != nil {
		log.Fatal("Error apollo-webserver ListenAndServe: ", err)
	}
}
<commit_msg>Added organizations handlers to apollo-webserver<commit_after>package main

import (
	"flag"
	"fmt"
	"log"
	"net/http"

	"github.com/globocom/config"
	"github.com/gorilla/mux"

	"github.com/wiliamsouza/apollo/api"
	"github.com/wiliamsouza/apollo/db"
)

const version = "0.0.1"

type MuxHandler func(http.ResponseWriter, *http.Request, map[string]string)

func (h MuxHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	h(w, r, vars)
}

func main() {
	configFile := flag.String("config", "/etc/apollo.conf", "Apollo webserver configuration file")
	gVersion := flag.Bool("version", false, "Print version and exit")

	flag.Parse()

	if *gVersion {
		fmt.Printf("apollo-webserver version %s\n", version)
		return
	}
	err := config.ReadAndWatchConfigFile(*configFile)
	if err != nil {
		msg := `Could not find apollo config file. Searched on %s. For an example conf check /etc/apollo.conf file.\n %s`
		log.Panicf(msg, *configFile, err)
	}

	db.Connect()

	r := mux.NewRouter()
	r.HandleFunc("/tests/packages", api.ListPackages).Methods("GET")
	r.HandleFunc("/tests/packages", api.UploadPackage).Methods("POST")
	r.HandleFunc("/tests/packages/{filename}", api.DetailPackage).Methods("GET")
	r.HandleFunc("/tests/packages/downloads/{filename}", api.DownloadPackage).Methods("GET")
	r.HandleFunc("/users", api.NewUser).Methods("POST")
	r.HandleFunc("/organizations", api.NewOrganization).Methods("POST")
	r.HandleFunc("/organizations", api.ListOrganizations).Methods("GET")
	r.Handle("/organizations/{name}", MuxHandler(api.DetailOrganization)).Methods("GET")
	r.Handle("/organizations/{name}", MuxHandler(api.ModifyOrganization)).Methods("PUT")
	r.Handle("/organizations/{name}", MuxHandler(api.DeleteOrganization)).Methods("DELETE")

	http.Handle("/", r)

	bind, err := config.GetString("webserver:bind")
	if err != nil {
		panic(err)
	}

	err = http.ListenAndServe(bind, nil)
	if err != nil {
		log.Fatal("Error apollo-webserver ListenAndServe: ", err)
	}
}

{'fraction_non_alphanumeric': 0.17553827751196172, 'fraction_numerical': 0.0017942583732057417, 'mean_word_length': 4.973214285714286, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5966849', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1177, 'n_words': 223}