Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 919451c

Browse files
committedAug 10, 2020
add: new default request.
1 parent e936303 commit 919451c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
 

‎request.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package got
2+
3+
import (
4+
"net/http"
5+
)
6+
7+
// DefaulUserAgent is the default Got user agent to send http request.
8+
const DefaulUserAgent = "Got/1.0"
9+
10+
// NewRequest returns a new http.Request and error if any.
11+
func NewRequest(method, URL string) (*http.Request, error) {
12+
13+
req, err := http.NewRequest(method, URL, nil)
14+
15+
if err != nil {
16+
return nil, err
17+
}
18+
19+
req.Header.Set("User-Agent", DefaulUserAgent)
20+
21+
return req, nil
22+
}

0 commit comments

Comments
 (0)