<commit_before>package main

import "fmt"
import "net/http"
import "encoding/json" // documentation: http://golang.org/pkg/encoding/json/

//
// using gorest: https://code.google.com/p/gorest/wiki/GettingStarted?tm=6
//
import "code.google.com/p/gorest"

func main() {
	fmt.Println("Oh dear, a graph database...")
	gorest.RegisterService(new(GraphService))
	http.Handle("/", gorest.Handle())    
	http.ListenAndServe(":8777", nil)
}

type Node struct {
	Id int
	Name string
	ExtraJSONBytes []byte
	ExtraJSON []interface{}
}

type Edge struct {
	Id int
	Name string
	Source int
	Target int
	ExtraJSON []byte
}

type GraphService struct{
    // service level config
    gorest.RestService    `root:"/" consumes:"application/json" produces:"application/json"`
	// define routes
    rootHandler gorest.EndPoint `method:"GET" path:"/" output:"string"`
	getNodeHandler gorest.EndPoint `method:"GET" path:"/node/{Id:int}" output:"Node"`
	getEdgeHandler gorest.EndPoint `method:"GET" path:"/edge/{Id:int}" output:"Edge"`
}

func(serv GraphService) RootHandler() string {
	return "oh hello"
}

func(serv GraphService) GetNodeHandler(Id int) (n Node){
	fmt.Printf("Asking for node ID: %d \n", Id)
	
	n.Id = Id
	n.Name = "<NAME>"
	n.ExtraJSONBytes = []byte(`[{"Name": "Platypus", "Order": "Monotremata"}]`)
	
	var tmp interface {}
	err := json.Unmarshal(n.ExtraJSONBytes, &tmp)
	if err != nil {
			fmt.Println("error:", err)
		}
	//fmt.Printf("JSON: %T %+v \n", tmp, tmp)
	n.ExtraJSON = tmp.([]interface{})<commit_msg>- added comment about weird JSON technique for my own benefit<commit_after>package main

import "fmt"
import "net/http"
import "encoding/json" // documentation: http://golang.org/pkg/encoding/json/

//
// using gorest: https://code.google.com/p/gorest/wiki/GettingStarted?tm=6
//
import "code.google.com/p/gorest"

func main() {
	fmt.Println("Oh dear, a graph database...")
	gorest.RegisterService(new(GraphService))
	http.Handle("/", gorest.Handle())    
	http.ListenAndServe(":8777", nil)
}

type Node struct {
	Id int
	Name string
	ExtraJSONBytes []byte
	ExtraJSON []interface{}
}

type Edge struct {
	Id int
	Name string
	Source int
	Target int
	ExtraJSON []byte
}

type GraphService struct{
    // service level config
    gorest.RestService    `root:"/" consumes:"application/json" produces:"application/json"`
	// define routes
    rootHandler gorest.EndPoint `method:"GET" path:"/" output:"string"`
	getNodeHandler gorest.EndPoint `method:"GET" path:"/node/{Id:int}" output:"Node"`
	getEdgeHandler gorest.EndPoint `method:"GET" path:"/edge/{Id:int}" output:"Edge"`
}

func(serv GraphService) RootHandler() string {
	return "oh hello"
}

func(serv GraphService) GetNodeHandler(Id int) (n Node){
	fmt.Printf("Asking for node ID: %d \n", Id)
	
	n.Id = Id
	n.Name = "<NAME>"
	n.ExtraJSONBytes = []byte(`[{"Name": "Platypus", "Order": "Monotremata"}]`)
	
	// this technique of taking arbitrary JSON and turning it into something usable came from: http://blog.golang.org/json-and-go
	var tmp interface {}
	err := json.Unmarshal(n.ExtraJSONBytes, &tmp)
	if err != nil {
			fmt.Println("error:", err)
		}
	//fmt.Printf("JSON: %T %+v \n", tmp, tmp)
	n.ExtraJSON = tmp.([]interface{})
{'fraction_non_alphanumeric': 0.16682345562872375, 'fraction_numerical': 0.0031357792411414237, 'mean_word_length': 4.352348993288591, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1800284', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1090, 'n_words': 276}