Use lowerCamelCase for the JSON API (fixes #1338)
Replace the current mix of UpperCamelCase und lowerCamelCase with consistent lowerCamelCase keys for the JSON API. Also adapt the frontend so it works with the changed API. Attention: this will break existing consumers of the API.
This commit is contained in:
@@ -18,6 +18,7 @@ package model
|
||||
import (
|
||||
"bufio"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -241,6 +242,16 @@ type ConnectionInfo struct {
|
||||
ClientVersion string
|
||||
}
|
||||
|
||||
func (info ConnectionInfo) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(map[string]interface{}{
|
||||
"at": info.At,
|
||||
"inBytesTotal": info.InBytesTotal,
|
||||
"outBytesTotal": info.OutBytesTotal,
|
||||
"address": info.Address,
|
||||
"clientVersion": info.ClientVersion,
|
||||
})
|
||||
}
|
||||
|
||||
// ConnectionStats returns a map with connection statistics for each connected device.
|
||||
func (m *Model) ConnectionStats() map[string]ConnectionInfo {
|
||||
type remoteAddrer interface {
|
||||
|
||||
Reference in New Issue
Block a user