Skip to content

Commit

Permalink
fixed: remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
primalmotion committed Mar 1, 2018
1 parent f155c26 commit c0589d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 36 deletions.
57 changes: 24 additions & 33 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,31 @@ import (
"strconv"
"strings"

"github.com/opentracing/opentracing-go"

uuid "github.com/satori/go.uuid"
)

// A Request represents an abstract request on an elemental model.
type Request struct {
RequestID string `json:"rid"`
Namespace string `json:"namespace"`
Recursive bool `json:"recursive"`
Operation Operation `json:"operation"`
Identity Identity `json:"identity"`
Order []string `json:"order"`
ObjectID string `json:"objectID"`
ParentIdentity Identity `json:"parentIdentity"`
ParentID string `json:"parentID"`
Data json.RawMessage `json:"data,omitempty"`
Parameters url.Values `json:"parameters,omitempty"`
Headers http.Header `json:"headers,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Page int `json:"page,omitempty"`
PageSize int `json:"pageSize,omitempty"`
OverrideProtection bool `json:"overrideProtection,omitempty"`
Version int `json:"version,omitempty"`
TrackingData opentracing.TextMapCarrier `json:"trackingData,omitempty"`
ExternalTrackingID string `json:"externalTrackingID,omitempty"`
ExternalTrackingType string `json:"externalTrackingType,omitempty"`
RequestID string `json:"rid"`
Namespace string `json:"namespace"`
Recursive bool `json:"recursive"`
Operation Operation `json:"operation"`
Identity Identity `json:"identity"`
Order []string `json:"order"`
ObjectID string `json:"objectID"`
ParentIdentity Identity `json:"parentIdentity"`
ParentID string `json:"parentID"`
Data json.RawMessage `json:"data,omitempty"`
Parameters url.Values `json:"parameters,omitempty"`
Headers http.Header `json:"headers,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
Page int `json:"page,omitempty"`
PageSize int `json:"pageSize,omitempty"`
OverrideProtection bool `json:"overrideProtection,omitempty"`
Version int `json:"version,omitempty"`
ExternalTrackingID string `json:"externalTrackingID,omitempty"`
ExternalTrackingType string `json:"externalTrackingType,omitempty"`

Metadata map[string]interface{} `json:"-"`
ClientIP string `json:"-"`
Expand All @@ -50,11 +47,10 @@ type Request struct {
func NewRequest() *Request {

return &Request{
RequestID: uuid.Must(uuid.NewV4()).String(),
Parameters: url.Values{},
Headers: http.Header{},
Metadata: map[string]interface{}{},
TrackingData: opentracing.TextMapCarrier{},
RequestID: uuid.Must(uuid.NewV4()).String(),
Parameters: url.Values{},
Headers: http.Header{},
Metadata: map[string]interface{}{},
}
}

Expand Down Expand Up @@ -195,7 +191,6 @@ func NewRequestFromHTTPRequest(req *http.Request) (*Request, error) {
OverrideProtection: override,
Metadata: map[string]interface{}{},
Version: version,
TrackingData: opentracing.TextMapCarrier{},
ExternalTrackingID: req.Header.Get("X-External-Tracking-ID"),
ExternalTrackingType: req.Header.Get("X-External-Tracking-Type"),
Order: req.URL.Query()["order"],
Expand Down Expand Up @@ -242,10 +237,6 @@ func (r *Request) Duplicate() *Request {
req.Metadata[k] = v
}

for k, v := range r.TrackingData {
req.TrackingData[k] = v
}

return req
}

Expand Down
3 changes: 0 additions & 3 deletions request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/url"
"testing"

opentracing "github.com/opentracing/opentracing-go"
. "github.com/smartystreets/goconvey/convey"
)

Expand Down Expand Up @@ -751,7 +750,6 @@ func TestRequest_Duplicate(t *testing.T) {
req.Version = 12
req.Order = []string{"key1", "key2"}
req.ClientIP = "1.2.3.4"
req.TrackingData = opentracing.TextMapCarrier{"a": "b"}
req.Metadata = map[string]interface{}{"a": 1}

Convey("When I use Duplicate()", func() {
Expand All @@ -777,7 +775,6 @@ func TestRequest_Duplicate(t *testing.T) {
So(req2.Version, ShouldEqual, req.Version)
So(req2.Order, ShouldResemble, req.Order)
So(req2.ClientIP, ShouldResemble, req.ClientIP)
So(req2.TrackingData, ShouldResemble, req.TrackingData)
So(req2.Metadata, ShouldResemble, req.Metadata)
})
})
Expand Down

0 comments on commit c0589d1

Please sign in to comment.