<commit_before>package hostqueue

import (
	"encoding/json"
	"net/http"
	"regexp"
	"strings"

	"appengine"

	"github.com/gorilla/mux"
)

//group/status/{groupUUID}
//Respond with the group name, current queue, who is up next in that queue, and if this week has a host yet.
func DisplayGroupStatus(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	pathVars := mux.Vars(r)
	AddUuid(c)

	uuid := pathVars["uuid"]
	c.Infof("URI", strings.Split(r.URL.Path, "/"))
	c.Infof("UUID", uuid)

	if isValidUUID((uuid)) {
		group, err := GetGroupByUUID(c, uuid)

		if err != nil {
			//c.Infof()
			w.Write([]byte("invalid group"))
		}

		jsonGroup, err := json.Marshal(group)
		if err != nil {
			panic(err)
		}
		w.Header().Set("Content-Type", "application/json")
		w.Write(jsonGroup)
	}

	w.Write([]byte("invalid group"))
}

func isValidUUID(text string) bool {
	r := regexp.MustCompile("^[a-z0-9]{8}-[a-z0-9]{4}-[1-5][a-z0-9]{3}-[a-z0-9]{4}-[a-z0-9]{12}$")
	return r.MatchString(text)
}<commit_msg>added gorilla mux to handle path variables.<commit_after>package hostqueue

import (
	"encoding/json"
	"net/http"
	"regexp"
	"strings"

	"appengine"

	"github.com/gorilla/mux"
)

//group/status/{groupUUID}
//Respond with the group name, current queue, who is up next in that queue, and if this week has a host yet.
func DisplayGroupStatus(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	pathVars := mux.Vars(r)
	AddUuid(c)

	uuid := pathVars["uuid"]
	c.Infof("UUID: %s", uuid)

	if isValidUUID((uuid)) {
		group, err := GetGroupByUUID(c, uuid)
		c.Infof("group: %v", group)
		if err != nil {
			//c.Infof()
			w.Write([]byte("invalid group"))
		}

		jsonGroup, err := json.Marshal(group)
		if err != nil {
			panic(err)
		}
		w.Header().Set("Content-Type", "application/json")
		w.Write(jsonGroup)
	}

	w.Write([]byte("invalid group"))
}

func isValidUUID(text string) bool {
	r := regexp.MustCompile("^[a-z0-9]{8}-[a-z0-9]{4}-[1-5][a-z0-9]{3}-[a-z0-9]{4}-[a-z0-9]{12}$")
	return r.MatchString(text)
}
{'fraction_non_alphanumeric': 0.1953853706431026, 'fraction_numerical': 0.017673048600883652, 'mean_word_length': 3.9828850855745723, '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': '740607', 'n_tokens_mistral': 864, 'n_tokens_neox': 831, 'n_words': 168}