diff --git a/doc.go b/doc.go index bc68680..1485abc 100644 --- a/doc.go +++ b/doc.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* Package wrp defines the various WRP messages supported by WebPA and implements serialization for those messages. diff --git a/format.go b/format.go index 1c4be53..6263a2b 100644 --- a/format.go +++ b/format.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrp import ( diff --git a/format_test.go b/format_test.go index d89c4bf..5d7289d 100644 --- a/format_test.go +++ b/format_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrp import ( diff --git a/go.mod b/go.mod index b945a31..1fd3bdd 100644 --- a/go.mod +++ b/go.mod @@ -3,14 +3,13 @@ module github.com/xmidt-org/wrp-go/v3 go 1.13 require ( - github.com/davecgh/go-spew v1.1.1-0.20171005155431-ecdeabc65495 + github.com/davecgh/go-spew v1.1.1 github.com/go-kit/kit v0.8.0 github.com/go-logfmt/logfmt v0.3.0 // indirect github.com/go-stack/stack v1.8.0 // indirect github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/objx v0.1.2-0.20180825064932-ef50b0de2877 // indirect - github.com/stretchr/testify v1.2.1 + github.com/stretchr/testify v1.7.0 github.com/ugorji/go/codec v1.2.6 + github.com/xmidt-org/httpaux v0.3.0 github.com/xmidt-org/webpa-common v1.3.2 ) diff --git a/go.sum b/go.sum index a30917f..a1d9119 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,6 @@ -github.com/davecgh/go-spew v1.1.1-0.20171005155431-ecdeabc65495 h1:b2hEFhj0PgDc77eCeDUSKXynIoXJRt6yTZ8aMk2cPoI= -github.com/davecgh/go-spew v1.1.1-0.20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0 h1:8HUsc87TaSWLKwrnumgC8/YconD2fJQsRJAsWaPg2ic= @@ -10,13 +11,22 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.2-0.20180825064932-ef50b0de2877 h1:6K1nYEj5Y6jqgsc/SWBuF7YcLqaQbWSNAmf4LtApioo= -github.com/stretchr/objx v0.1.2-0.20180825064932-ef50b0de2877/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U= -github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As= +github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/ugorji/go v1.2.6 h1:tGiWC9HENWE2tqYycIqFTNorMmFRVhNwCpDOpWqnk8E= github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0= github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ= github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= +github.com/xmidt-org/httpaux v0.3.0 h1:JdV4QceiE8EMA1Qf5rnJzHdkIPzQV12ddARHLU8hrTs= +github.com/xmidt-org/httpaux v0.3.0/go.mod h1:mviIlg5fHGb3lAv3l0sbiwVG/q9rqvXaudEYxVrzXdE= github.com/xmidt-org/webpa-common v1.3.2 h1:dE1Fi+XVnkt3tMGMjH7/hN/UGcaQ/ukKriXuMDyCWnM= github.com/xmidt-org/webpa-common v1.3.2/go.mod h1:oCpKzOC+9h2vYHVzAU/06tDTQuBN4RZz+rhgIXptpOI= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/header_wrp.go b/header_wrp.go index fe77066..26feeaf 100644 --- a/header_wrp.go +++ b/header_wrp.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrp import ( diff --git a/messages.go b/messages.go index b305eea..9332d52 100644 --- a/messages.go +++ b/messages.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrp import "regexp" diff --git a/messages_test.go b/messages_test.go index 64fdc43..989b0a0 100644 --- a/messages_test.go +++ b/messages_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrp import ( diff --git a/messagetype.go b/messagetype.go index 9a935a8..b2d5532 100644 --- a/messagetype.go +++ b/messagetype.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrp import ( diff --git a/messagetype_test.go b/messagetype_test.go index f93f3b6..41c96be 100644 --- a/messagetype_test.go +++ b/messagetype_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrp import ( diff --git a/wrpclient/mocks_test.go b/wrpclient/mocks_test.go new file mode 100644 index 0000000..793b204 --- /dev/null +++ b/wrpclient/mocks_test.go @@ -0,0 +1,38 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package wrpclient + +import ( + "bytes" + "io/ioutil" + "net/http" + + "github.com/stretchr/testify/mock" +) + +type mockHTTPClient struct { + mock.Mock +} + +func (m *mockHTTPClient) Do(req *http.Request) (*http.Response, error) { + args := m.Called(req) + return &http.Response{ + StatusCode: args.Int(0), + Body: ioutil.NopCloser(bytes.NewBuffer(args.Get(1).([]byte))), + }, nil +} diff --git a/wrpclient/wrpclient.go b/wrpclient/wrpclient.go new file mode 100644 index 0000000..352336b --- /dev/null +++ b/wrpclient/wrpclient.go @@ -0,0 +1,118 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package wrpclient + +import ( + "bytes" + "context" + "errors" + "fmt" + "net/http" + "net/url" + + "github.com/xmidt-org/httpaux/erraux" + "github.com/xmidt-org/wrp-go/v3" +) + +var ( + errEncoding = errors.New("encoding error") + errCreateRequest = errors.New("http request creation error") + errHTTPTransaction = errors.New("http transaction error") + errDecoding = errors.New("decoding response error") + errNonSuccessfulResponse = errors.New("non-200 response") + errInvalidRequestFormat = errors.New("invalid client RequestFormat") + errInvalidURL = errors.New("invalid client URL") +) + +type HTTPClient interface { + Do(*http.Request) (*http.Response, error) +} + +type Client struct { + + // URL is the full location for the serverside wrp endpoint. + // If unset, use talaria's URI at localhost, which is the port used in talaria's docker image + url string + + // RequestFormat is the wrp Format to use for all requests, which specifies the wrp.Encoder. + // If unset, defaults to JSON, which is what the wrp package defaults to. + requestFormat wrp.Format + + // If unset, defaults to net/http.DefaultClient + httpClient HTTPClient +} + +func New(reqURL string, reqFormat wrp.Format, httpClient HTTPClient) (*Client, error) { + c := Client{ + url: reqURL, + requestFormat: reqFormat, + httpClient: httpClient, + } + if c.url == "" { + c.url = "http://localhost:6200" + } + _, err := url.ParseRequestURI(c.url) + if err != nil { + return nil, fmt.Errorf("%w: %v", errInvalidURL, err) + } + if c.httpClient == nil { + c.httpClient = &http.Client{} + } + if c.requestFormat == 0 { + c.requestFormat = wrp.JSON + } else if c.requestFormat > 2 || c.requestFormat < 0 { + return nil, errInvalidRequestFormat + } + return &c, nil +} + +func (c *Client) SendWRP(ctx context.Context, response, request interface{}) error { + // Create an *http.Request, using c.RequestFormat to marshal the body and the client URL + var payload []byte + err := wrp.NewEncoderBytes(&payload, c.requestFormat).Encode(request) + if err != nil { + return fmt.Errorf("%w: %v", errEncoding, err) + } + r, err := http.NewRequestWithContext(ctx, http.MethodPost, c.url, bytes.NewBuffer(payload)) + if err != nil { + return fmt.Errorf("%w: %v", errCreateRequest, err) + } + + // Use c.HTTPClient or http.DefaultClient to execute the HTTP transaction + resp, err := c.httpClient.Do(r.WithContext(ctx)) + if err != nil { + return fmt.Errorf("%w: %v", errHTTPTransaction, err) + } else if resp.StatusCode >= 300 || resp.StatusCode < 200 { + err := &erraux.Error{ + Err: err, + Code: resp.StatusCode, + Message: resp.Status, + Header: resp.Header, + } + return fmt.Errorf("%w: %v", errNonSuccessfulResponse, err) + } + + // Translate the response using the wrp package and the response as the target of unmarshaling + defer resp.Body.Close() + err = wrp.NewDecoder(resp.Body, c.requestFormat).Decode(response) + if err != nil { + return fmt.Errorf("%w: %v", errDecoding, err) + } + + return nil +} diff --git a/wrpclient/wrpclient_test.go b/wrpclient/wrpclient_test.go new file mode 100644 index 0000000..49c816a --- /dev/null +++ b/wrpclient/wrpclient_test.go @@ -0,0 +1,187 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package wrpclient + +import ( + "context" + "errors" + "fmt" + "net/http" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "github.com/xmidt-org/wrp-go/v3" +) + +func TestNew(t *testing.T) { + defaultClient := Client{ + url: "http://localhost:6200", + httpClient: &http.Client{}, + requestFormat: 1, + } + tcs := []struct { + desc string + client Client + expectedClient Client + expectedErr error + }{ + { + desc: "Happy Input Client", + client: Client{ + url: "http://random.com", + httpClient: &http.Client{ + Timeout: 2, + }, + requestFormat: 2, + }, + expectedClient: Client{ + url: "http://random.com", + httpClient: &http.Client{ + Timeout: 2, + }, + requestFormat: 2, + }, + }, + { + desc: "Empty Client", + client: Client{}, + expectedClient: defaultClient, + }, + + { + desc: "Invalid requestFormat failure", + client: Client{ + requestFormat: 8, + }, + expectedErr: errInvalidRequestFormat, + }, + { + desc: "Invalid url failure", + client: Client{ + url: "nope", + }, + expectedErr: errInvalidURL, + }, + } + for _, tc := range tcs { + t.Run(tc.desc, func(t *testing.T) { + assert := assert.New(t) + client, err := New(tc.client.url, tc.client.requestFormat, tc.client.httpClient) + if tc.expectedErr != nil { + assert.True(errors.Is(err, tc.expectedErr), + fmt.Errorf("error [%v] doesn't contain error [%v] in its err chain", + err, tc.expectedErr), + ) + } else { + require.NoError(t, err) + assert.EqualValues(tc.expectedClient, *client) + } + + }) + } +} + +func TestSendWRP(t *testing.T) { + simpleMessage := &wrp.Message{ + Type: wrp.SimpleRequestResponseMessageType, + } + + tcs := []struct { + desc string + client Client + response interface{} + request interface{} + nilContext bool + expectedErr error + HTTPReturnCode int + HTTPPayload interface{} + useMockHTTPClient bool + }{ + { + desc: "Non 200 Response failure", + useMockHTTPClient: true, + expectedErr: errNonSuccessfulResponse, + HTTPReturnCode: 400, + HTTPPayload: simpleMessage, + }, + { + desc: "Request Creation failure", + nilContext: true, + expectedErr: errCreateRequest, + }, + { + desc: "HTTPClient Transaction failure", + expectedErr: errHTTPTransaction, + }, + { + desc: "Decode failure", + useMockHTTPClient: true, + HTTPReturnCode: 200, + HTTPPayload: "", + response: &wrp.Message{}, + request: &wrp.Message{}, + expectedErr: errDecoding, + }, + { + desc: "Happy Client and Path success", + useMockHTTPClient: true, + HTTPReturnCode: 200, + HTTPPayload: simpleMessage, + response: &wrp.Message{}, + request: &wrp.Message{}, + expectedErr: nil, + }, + } + + for _, tc := range tcs { + + t.Run(tc.desc, func(t *testing.T) { + assert := assert.New(t) + + var ctx context.Context + if tc.nilContext { + ctx = nil + } else { + ctx = context.Background() + } + + var payload []byte + err := wrp.NewEncoderBytes(&payload, wrp.JSON).Encode(tc.HTTPPayload) + require.NoError(t, err) + m := new(mockHTTPClient) + m.On("Do", mock.AnythingOfType("*http.Request")).Return(tc.HTTPReturnCode, payload) + client, err := New("", wrp.JSON, nil) + require.NoError(t, err) + if tc.useMockHTTPClient { + client.httpClient = m + } + + err = client.SendWRP(ctx, &tc.response, &tc.request) + if tc.useMockHTTPClient { + m.AssertExpectations(t) + } + + assert.True(errors.Is(err, tc.expectedErr), + fmt.Errorf("error [%v] doesn't contain error [%v] in its err chain", + err, tc.expectedErr), + ) + }) + } +} diff --git a/wrpendpoint/doc.go b/wrpendpoint/doc.go index bb07234..8ab93b7 100644 --- a/wrpendpoint/doc.go +++ b/wrpendpoint/doc.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* Package wrpendpoint integrates go-kit endpoints with the notion of services that consume and emit WRP. Code in this package is transport-neutral. See the wrp/wrphttp package for HTTP-specific integrations with go-kit's diff --git a/wrpendpoint/endpoint.go b/wrpendpoint/endpoint.go index e6143b4..1c22173 100644 --- a/wrpendpoint/endpoint.go +++ b/wrpendpoint/endpoint.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrpendpoint import ( diff --git a/wrpendpoint/endpoint_test.go b/wrpendpoint/endpoint_test.go index 306f3b5..dce98c3 100644 --- a/wrpendpoint/endpoint_test.go +++ b/wrpendpoint/endpoint_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrpendpoint import ( diff --git a/wrpendpoint/mocks_test.go b/wrpendpoint/mocks_test.go index 0b15149..028bc2e 100644 --- a/wrpendpoint/mocks_test.go +++ b/wrpendpoint/mocks_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrpendpoint import ( diff --git a/wrpendpoint/requestResponse.go b/wrpendpoint/requestResponse.go index 0de3a9a..c1f17d2 100644 --- a/wrpendpoint/requestResponse.go +++ b/wrpendpoint/requestResponse.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrpendpoint import ( diff --git a/wrpendpoint/requestResponse_test.go b/wrpendpoint/requestResponse_test.go index 29b9624..cdd6e29 100644 --- a/wrpendpoint/requestResponse_test.go +++ b/wrpendpoint/requestResponse_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrpendpoint import ( diff --git a/wrpendpoint/service.go b/wrpendpoint/service.go index a3ed845..e036c90 100644 --- a/wrpendpoint/service.go +++ b/wrpendpoint/service.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrpendpoint import ( diff --git a/wrpendpoint/service_test.go b/wrpendpoint/service_test.go index 836d88f..d5244c9 100644 --- a/wrpendpoint/service_test.go +++ b/wrpendpoint/service_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrpendpoint import ( diff --git a/wrphttp/decoders.go b/wrphttp/decoders.go index b248ac5..a1634ab 100644 --- a/wrphttp/decoders.go +++ b/wrphttp/decoders.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrphttp import ( diff --git a/wrphttp/decoders_test.go b/wrphttp/decoders_test.go index b58384c..77866a9 100644 --- a/wrphttp/decoders_test.go +++ b/wrphttp/decoders_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrphttp import ( diff --git a/wrphttp/doc.go b/wrphttp/doc.go index 3c26e31..6ca20a3 100644 --- a/wrphttp/doc.go +++ b/wrphttp/doc.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + /* Package wrphttp integrates go-kit's transport/http package with the patterns used by WebPA/XMiDT servers. Primarily, this package concerns itself with translating between HTTP requests and responses and WRP requests diff --git a/wrphttp/handler.go b/wrphttp/handler.go index 9633414..db2ffdf 100644 --- a/wrphttp/handler.go +++ b/wrphttp/handler.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrphttp import ( diff --git a/wrphttp/handler_test.go b/wrphttp/handler_test.go index 0b6e6cc..c79a44d 100644 --- a/wrphttp/handler_test.go +++ b/wrphttp/handler_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrphttp import ( diff --git a/wrphttp/headers.go b/wrphttp/headers.go index ff148f1..65ff597 100644 --- a/wrphttp/headers.go +++ b/wrphttp/headers.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrphttp import ( diff --git a/wrphttp/headers_test.go b/wrphttp/headers_test.go index 3ffa69f..87501c0 100644 --- a/wrphttp/headers_test.go +++ b/wrphttp/headers_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrphttp import ( diff --git a/wrphttp/mocks.go b/wrphttp/mocks.go index 3777e43..938ea27 100644 --- a/wrphttp/mocks.go +++ b/wrphttp/mocks.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrphttp import ( diff --git a/wrphttp/mocks_test.go b/wrphttp/mocks_test.go index f30d5e4..ffd9093 100644 --- a/wrphttp/mocks_test.go +++ b/wrphttp/mocks_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrphttp import ( diff --git a/wrphttp/requestResponse.go b/wrphttp/requestResponse.go index 2cb03ff..3b76e1b 100644 --- a/wrphttp/requestResponse.go +++ b/wrphttp/requestResponse.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrphttp import ( diff --git a/wrphttp/requestResponse_test.go b/wrphttp/requestResponse_test.go index 26d08a1..8ddd27c 100644 --- a/wrphttp/requestResponse_test.go +++ b/wrphttp/requestResponse_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrphttp import ( diff --git a/wrpmeta/doc.go b/wrpmeta/doc.go index e99c0a0..7aa8dde 100644 --- a/wrpmeta/doc.go +++ b/wrpmeta/doc.go @@ -1,2 +1,19 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + // Package wrpmeta provides a simple API for building WRP message metadata package wrpmeta diff --git a/wrpmeta/metadata.go b/wrpmeta/metadata.go index 5c710d6..f43f200 100644 --- a/wrpmeta/metadata.go +++ b/wrpmeta/metadata.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrpmeta import "fmt" diff --git a/wrpmeta/metadata_test.go b/wrpmeta/metadata_test.go index 8a8ff0c..2a7f6c7 100644 --- a/wrpmeta/metadata_test.go +++ b/wrpmeta/metadata_test.go @@ -1,3 +1,20 @@ +/** + * Copyright 2022 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package wrpmeta import (