Respond with CORS ok and json indent
parent
4ac316f49d
commit
098a2b9bbc
|
|
@ -21,6 +21,7 @@ func Html(g storage.Graph) error {
|
||||||
|
|
||||||
func foo(g storage.Graph) http.Handler {
|
func foo(g storage.Graph) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
var err error
|
var err error
|
||||||
switch path.Base(r.URL.Path) {
|
switch path.Base(r.URL.Path) {
|
||||||
case "who":
|
case "who":
|
||||||
|
|
@ -65,8 +66,9 @@ func who(g storage.Graph, w http.ResponseWriter, r *http.Request) error {
|
||||||
for j := range one.Connections {
|
for j := range one.Connections {
|
||||||
if one.Connections[j].Name == another.Name {
|
if one.Connections[j].Name == another.Name {
|
||||||
one.Connections[j] = entity.One{
|
one.Connections[j] = entity.One{
|
||||||
Name: another.Name,
|
|
||||||
Relationship: one.Connections[j].Relationship,
|
Relationship: one.Connections[j].Relationship,
|
||||||
|
Type: another.Type,
|
||||||
|
Modified: another.Modified,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,5 +77,7 @@ func who(g storage.Graph, w http.ResponseWriter, r *http.Request) error {
|
||||||
results[id] = one
|
results[id] = one
|
||||||
}
|
}
|
||||||
log.Println("results:", results)
|
log.Println("results:", results)
|
||||||
return json.NewEncoder(w).Encode(results)
|
enc := json.NewEncoder(w)
|
||||||
|
enc.SetIndent("", " ")
|
||||||
|
return enc.Encode(results)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue