Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Obtain status info in JSON format #359

Merged
merged 4 commits into from
Feb 25, 2015
Merged

Conversation

bboreham
Copy link
Contributor

Json generation is done by creating dummy structs and arrays that match the format we want, copying the information into them, then getting Go's standard json encoder to do the work.

All the implementation is pulled into one file json.go rather than scattering it across all the relevant implementations; at time of writing this seems easier to grasp.

bboreham added a commit to bboreham/weave that referenced this pull request Jan 21, 2015
@rade
Copy link
Member

rade commented Feb 1, 2015

@squaremo mind taking a look at this?

@@ -145,6 +145,11 @@ func handleHttp(router *weave.Router) {
io.WriteString(w, fmt.Sprintln("Encryption", encryption))
io.WriteString(w, router.Status())
})
http.HandleFunc("/status-json", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")

This comment was marked as abuse.

@squaremo
Copy link
Contributor

squaremo commented Feb 2, 2015

What's the argument for using specialise methods rather than giving the struct definitions tags -- just that the data aren't quite organised in the right way?

@bboreham
Copy link
Contributor Author

bboreham commented Feb 2, 2015

Taking the structs one at a time:
Router - need to specify the way the Interface is encoded; can't directly override what net.Interface does.
MacCache - the table is keyed on a uint64 encoding of the mac address; this would look ugly. Also it is not exported so go's json encoder would ignore it.
Peers - table is not exported, and want to render the *Peer references as names only.
Routes - again, fields are not exported, and while the default rendering would contain the right information it will be in a hard-to-understand format, just 'peername : peername' for each entry.
Peers - changing connections from a map into an array
RemoteConnection - fields are not exported, and want to render the *Peer references as names only.

@bboreham
Copy link
Contributor Author

bboreham commented Feb 6, 2015

@squaremo I added top-level version and encryption info

@squaremo squaremo self-assigned this Feb 25, 2015
@squaremo squaremo merged commit 4109729 into weaveworks:master Feb 25, 2015
@rade rade mentioned this pull request Mar 9, 2015
@rade rade modified the milestone: 0.10.0 Apr 18, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants