diff --git a/server/server.go b/server/server.go index dfd18cf..fac13d8 100644 --- a/server/server.go +++ b/server/server.go @@ -21,10 +21,6 @@ type reflectionSpec struct { LogMessage string `json:"logMessage"` } -type capabilitiesSpec struct { - Endpoints []endpoint `json:"endpoints" yaml:"endpoints"` -} - type endpoint struct { Path string `json:"path" yaml:"path"` Methods []string `json:"methods,omitempty" yaml:"methods"` @@ -166,14 +162,14 @@ func handleReflect(w http.ResponseWriter, r *http.Request) { func handleCapabilities(w http.ResponseWriter, r *http.Request) { w.Header().Add("Content-Type", "application/json") - spec := &capabilitiesSpec{} + spec := &CapabilitiesSpec{} err := yaml.Unmarshal([]byte(capabilitiesDescription), spec) if err != nil { log.Fatal("Failed to unmarshal capabilities description") } if r.URL.Query().Get("quiet") == "true" { - quietSpec := &capabilitiesSpec{} + quietSpec := &CapabilitiesSpec{} for _, ep := range spec.Endpoints { quietSpec.Endpoints = append(quietSpec.Endpoints, endpoint{Path: ep.Path}) } diff --git a/server/server_test.go b/server/server_test.go index 31ee1c3..63671bd 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -142,7 +142,7 @@ func (s *serverTestSuite) TestCapabilities() { body, err := io.ReadAll(response.Body) s.Require().NoError(err) - spec := &capabilitiesSpec{} + spec := &CapabilitiesSpec{} err = json.Unmarshal(body, spec) s.Require().NoError(err) @@ -175,7 +175,7 @@ func (s *serverTestSuite) TestCapabilities_Quiet() { s.NotContains("contentType", string(body)) s.NotContains("description", string(body)) - spec := &capabilitiesSpec{} + spec := &CapabilitiesSpec{} err = json.Unmarshal(body, spec) s.Require().NoError(err) diff --git a/server/types.go b/server/types.go new file mode 100644 index 0000000..1cef4d5 --- /dev/null +++ b/server/types.go @@ -0,0 +1,5 @@ +package server + +type CapabilitiesSpec struct { + Endpoints []endpoint `json:"endpoints" yaml:"endpoints"` +}