github.com/vnforks/kid@v5.11.1+incompatible/services/httpservice/transport.go (about) 1 // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package httpservice 5 6 import ( 7 "net/http" 8 ) 9 10 // MattermostTransport is an implementation of http.RoundTripper that ensures each request contains a custom user agent 11 // string to indicate that the request is coming from a Mattermost instance. 12 type MattermostTransport struct { 13 // Transport is the underlying http.RoundTripper that is actually used to make the request 14 Transport http.RoundTripper 15 } 16 17 func (t *MattermostTransport) RoundTrip(req *http.Request) (*http.Response, error) { 18 req.Header.Set("User-Agent", defaultUserAgent) 19 20 return t.Transport.RoundTrip(req) 21 }