Documentation ¶
Overview ¶
net package is a dedicated hybrid network wrapper for TEP.
It may have some impact on performance due to one or more additional allocations.
Index ¶
- Constants
- func Copy(w io.Writer, r io.Reader) (int64, error)
- type FastHTTP
- type FastHTTPRequest
- func (f *FastHTTPRequest) Body() io.Writer
- func (f *FastHTTPRequest) Do() error
- func (f *FastHTTPRequest) MethodGET()
- func (f *FastHTTPRequest) MethodPOST()
- func (f *FastHTTPRequest) Reset()
- func (f *FastHTTPRequest) SetContentType(v string)
- func (f *FastHTTPRequest) SetRequestURI(v string)
- func (f *FastHTTPRequest) SetWriteCloser(v io.ReadWriteCloser)
- func (f *FastHTTPRequest) SetWriter(w *bytes.Buffer)
- func (f *FastHTTPRequest) Write(b []byte)
- func (f *FastHTTPRequest) WriteFile(content string, r io.Reader) error
- func (f *FastHTTPRequest) WriteJson(v any) error
- type GoNet
- type GoNetRequest
- func (g *GoNetRequest) Body() io.Writer
- func (g *GoNetRequest) Do() error
- func (g *GoNetRequest) MethodGET()
- func (g *GoNetRequest) MethodPOST()
- func (g *GoNetRequest) Reset()
- func (g *GoNetRequest) SetContentType(v string)
- func (g *GoNetRequest) SetRequestURI(v string)
- func (g *GoNetRequest) SetWriteCloser(v io.ReadWriteCloser)
- func (g *GoNetRequest) SetWriter(w *bytes.Buffer)
- func (g *GoNetRequest) Write(b []byte)
- func (g *GoNetRequest) WriteFile(content string, r io.Reader) error
- func (g *GoNetRequest) WriteJson(v any) error
- type NetFrame
- type NetRequest
- type NetResponse
- type Response
Constants ¶
View Source
const UA = "Mozilla/5.0(compatible; Telebot/v2; +https://telebot.pkg.one)"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FastHTTP ¶
type FastHTTP struct {
// contains filtered or unexported fields
}
func (*FastHTTP) Acquire ¶
func (f *FastHTTP) Acquire() (NetRequest, NetResponse)
func (*FastHTTP) Release ¶
func (f *FastHTTP) Release(req NetRequest, resp NetResponse)
func (*FastHTTP) ReleaseRequest ¶
func (f *FastHTTP) ReleaseRequest(r NetRequest)
func (*FastHTTP) ReleaseResponse ¶
func (f *FastHTTP) ReleaseResponse(r NetResponse)
func (*FastHTTP) SetJsonHandle ¶
type FastHTTPRequest ¶
type FastHTTPRequest struct {
// contains filtered or unexported fields
}
func (*FastHTTPRequest) Body ¶
func (f *FastHTTPRequest) Body() io.Writer
Body returns writer for populating request body.
func (*FastHTTPRequest) Do ¶
func (f *FastHTTPRequest) Do() error
func (*FastHTTPRequest) MethodGET ¶
func (f *FastHTTPRequest) MethodGET()
func (*FastHTTPRequest) MethodPOST ¶
func (f *FastHTTPRequest) MethodPOST()
func (*FastHTTPRequest) Reset ¶
func (f *FastHTTPRequest) Reset()
func (*FastHTTPRequest) SetContentType ¶
func (f *FastHTTPRequest) SetContentType(v string)
func (*FastHTTPRequest) SetRequestURI ¶
func (f *FastHTTPRequest) SetRequestURI(v string)
func (*FastHTTPRequest) SetWriteCloser ¶
func (f *FastHTTPRequest) SetWriteCloser(v io.ReadWriteCloser)
func (*FastHTTPRequest) SetWriter ¶
func (f *FastHTTPRequest) SetWriter(w *bytes.Buffer)
func (*FastHTTPRequest) Write ¶
func (f *FastHTTPRequest) Write(b []byte)
func (*FastHTTPRequest) WriteFile ¶
func (f *FastHTTPRequest) WriteFile(content string, r io.Reader) error
func (*FastHTTPRequest) WriteJson ¶
func (f *FastHTTPRequest) WriteJson(v any) error
type GoNet ¶
type GoNet struct {
// contains filtered or unexported fields
}
func (*GoNet) Acquire ¶
func (g *GoNet) Acquire() (NetRequest, NetResponse)
func (*GoNet) Release ¶
func (g *GoNet) Release(req NetRequest, resp NetResponse)
func (*GoNet) ReleaseRequest ¶
func (g *GoNet) ReleaseRequest(r NetRequest)
func (*GoNet) ReleaseResponse ¶
func (g *GoNet) ReleaseResponse(r NetResponse)
func (*GoNet) SetJsonHandle ¶
type GoNetRequest ¶
type GoNetRequest struct {
// contains filtered or unexported fields
}
func (*GoNetRequest) Body ¶
func (g *GoNetRequest) Body() io.Writer
Body returns writer for populating request body.
func (*GoNetRequest) Do ¶
func (g *GoNetRequest) Do() error
func (*GoNetRequest) MethodGET ¶
func (g *GoNetRequest) MethodGET()
func (*GoNetRequest) MethodPOST ¶
func (g *GoNetRequest) MethodPOST()
func (*GoNetRequest) Reset ¶
func (g *GoNetRequest) Reset()
func (*GoNetRequest) SetContentType ¶
func (g *GoNetRequest) SetContentType(v string)
func (*GoNetRequest) SetRequestURI ¶
func (g *GoNetRequest) SetRequestURI(v string)
func (*GoNetRequest) SetWriteCloser ¶
func (g *GoNetRequest) SetWriteCloser(v io.ReadWriteCloser)
func (*GoNetRequest) SetWriter ¶
func (g *GoNetRequest) SetWriter(w *bytes.Buffer)
func (*GoNetRequest) Write ¶
func (g *GoNetRequest) Write(b []byte)
func (*GoNetRequest) WriteFile ¶
func (g *GoNetRequest) WriteFile(content string, r io.Reader) error
func (*GoNetRequest) WriteJson ¶
func (g *GoNetRequest) WriteJson(v any) error
type NetFrame ¶
type NetFrame interface { // Set up Json handler SetJsonHandle(v json.Json) // Create a new request object Acquire() (NetRequest, NetResponse) ReleaseRequest(r NetRequest) ReleaseResponse(r NetResponse) Release(req NetRequest, resp NetResponse) }
func NewFastHTTPClient ¶
func NewFastHTTPClient() NetFrame
func NewHTTPClient ¶
func NewHTTPClient() NetFrame
type NetRequest ¶
type NetRequest interface { // Set the request method to POST. MethodPOST() // Set the request method to GET。 MethodGET() // Only fasthttp Body() io.Writer // Set Content-Type SetContentType(v string) // Set the requested URI address SetRequestURI(v string) // Set a Writer. When this Writer is passed in, // the data will be written directly to the Writer // after the request is completed instead of passing in the Response. SetWriter(w *bytes.Buffer) // Set a Writer. When this Writer is passed in, // the data will be written directly to the Writer // after the request is completed instead of passing in the Response. SetWriteCloser(v io.ReadWriteCloser) // Write data to the Body. Write(b []byte) // Write files to Body. WriteFile(content string, r io.Reader) error // Write the structure directly to the Body as json, // which will be processed by the interface. WriteJson(v any) error // Execute request. Do() error // Release() will clear the data in the current pointer. // It is recommended to call it within the Release() method instead // of calling it externally. Reset() }
type NetResponse ¶
type NetResponse interface { // StatusCode method returns the HTTP status code for the executed request. // // Example: 200 StatusCode() int // Example: // // Raw: 200 // fmt.Println(resp.IsStatusCode(444)) // // Output: false IsStatusCode(v int) bool // If SetWriter() is called in req, this method will // not be set (unless the status code is not 200) Bytes() []byte // Release() will clear the data in the current pointer. // It is recommended to call it within the Release() method instead // of calling it externally. Reset() }
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) IsStatusCode ¶
func (*Response) StatusCode ¶
Click to show internal directories.
Click to hide internal directories.