Add: httpx

main
git 2023-06-13 17:31:49 +08:00
parent 196eb315df
commit fe62b1d0d7
Signed by: git
GPG Key ID: 3F65EFFA44207ADD
2 changed files with 46 additions and 0 deletions

13
httpx/example/main.go Normal file
View File

@ -0,0 +1,13 @@
package main
import (
"fmt"
"git.ifooth.com/common/pkg/httpx"
)
func main() {
client := httpx.C()
resp, err := client.R().Get("https://ifooth.com")
fmt.Println(resp, err)
}

33
httpx/http.go Normal file
View File

@ -0,0 +1,33 @@
package httpx
import "net/http"
// Request :
type Request struct {
raw *http.Request
}
// Get :
func (r *Request) Get(u string) (*Response, error) {
return &Response{raw: &http.Response{}}, nil
}
// Response :
type Response struct {
raw *http.Response
}
// Client :
type Client struct {
raw *http.Client
}
// R :
func (c *Client) R() *Request {
return &Request{raw: &http.Request{}}
}
// C :
func C() *Client {
return &Client{raw: &http.Client{}}
}