From f07dfc3a332a61ab65de46c49c4cfce4ba37b0a3 Mon Sep 17 00:00:00 2001 From: nxshock Date: Sat, 20 Jul 2019 22:10:43 +0500 Subject: [PATCH] Move versions method to separate model --- internal/handlers.go | 3 ++- internal/models/replies.go | 6 ------ internal/models/versions/reply.go | 7 +++++++ 3 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 internal/models/versions/reply.go diff --git a/internal/handlers.go b/internal/handlers.go index b140178..31d7ee8 100644 --- a/internal/handlers.go +++ b/internal/handlers.go @@ -14,6 +14,7 @@ import ( login "github.com/nxshock/signaller/internal/models/login" register "github.com/nxshock/signaller/internal/models/register" mSync "github.com/nxshock/signaller/internal/models/sync" + "github.com/nxshock/signaller/internal/models/versions" ) func RootHandler(w http.ResponseWriter, r *http.Request) { @@ -27,7 +28,7 @@ func VersionHandler(w http.ResponseWriter, r *http.Request) { return } - response := models.VersionsReply{Versions: []string{Version}} + response := versions.Reply{Versions: []string{Version}} sendJsonResponse(w, http.StatusOK, response) } diff --git a/internal/models/replies.go b/internal/models/replies.go index 25489ac..daae4f3 100644 --- a/internal/models/replies.go +++ b/internal/models/replies.go @@ -4,12 +4,6 @@ import ( common "github.com/nxshock/signaller/internal/models/common" ) -// https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-versions -type VersionsReply struct { - Versions []string `json:"versions"` // The supported versions. - UnstableFeatures map[string]bool `json:"unstable_features,omitempty"` -} - // https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-account-whoami type WhoAmIReply struct { UserID string `json:"user_id"` // Required. The user id that owns the access token. diff --git a/internal/models/versions/reply.go b/internal/models/versions/reply.go new file mode 100644 index 0000000..423cf78 --- /dev/null +++ b/internal/models/versions/reply.go @@ -0,0 +1,7 @@ +package versions + +// https://matrix.org/docs/spec/client_server/latest#get-matrix-client-versions +type Reply struct { + Versions []string `json:"versions"` // The supported versions. + UnstableFeatures map[string]bool `json:"unstable_features,omitempty"` // Experimental features the server supports. Features not listed here, or the lack of this property all together, indicate that a feature is not supported. +}