Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct { PORT string // The port number for the engine. DOMAIN string // The domain of the engine. SUBS []string // The subdomains of the engine. // contains filtered or unexported fields }
Engine represents an HTTP engine. It is responsible for managing network listeners and the HTTP server for either standard or secure connections, keeping track of its running status and configuration details like port, domain, and subdomains.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient represents an HTTP client. It encapsulates the functionality for sending HTTP requests and receiving responses, handling underlying client and transport configurations.
func NewHTTPClient ¶
func NewHTTPClient() *HTTPClient
NewHTTPClient initializes a new HTTPClient and returns its pointer. This function sets up the HTTP client with a custom transport configuration, including TLS settings and default timeout.
Returns: - *HTTPClient: A pointer to the newly created HTTPClient.
func (*HTTPClient) Send ¶
func (c *HTTPClient) Send(req *generated.Request) *generated.Response
Send sends an HTTP request and returns the HTTP response. This method constructs and sends an HTTP request based on the provided transport request, handling headers, method, endpoint, and body. It also processes the received HTTP response, extracting status, headers, and body.
Parameters: - req: *generated.Request The HTTP request to be sent.
Returns: - *generated.Response: The HTTP response received.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an HTTP server that handles both standard and secure connections. It encapsulates the functionality of two engines, one for handling standard HTTP connections and the other for secure HTTPS connections, along with a router for API routing.
func NewServer ¶
NewServer creates a new HTTP server based on the provided configuration. It initializes a standard and, if specified, a secure engine based on the server configuration.
Parameters: - cfg: *ServerCfg Configuration data for the HTTP server.
Returns: - *Server: A new HTTP server. - error: An error if any.
func (*Server) HTTPHandler ¶ added in v0.23.24
func (s *Server) HTTPHandler(w http.ResponseWriter, r *http.Request)
HTTPHandler handles HTTP requests and sends back HTTP responses. It processes incoming HTTP requests, creates a corresponding transport request, and uses the router to generate a response. The handler deals with various HTTP methods, reads request bodies if necessary, and writes back responses including headers and status codes.
Parameters: - w: http.ResponseWriter Response writer to send back the HTTP response. - r: *http.Request The incoming HTTP request to be processed.
type ServerCfg ¶
type ServerCfg struct { DOMAIN string // The domain of the server. SUBS []string // The subdomains of the server. HTTP string // The port number for HTTP connections. HTTPS string // The port number for HTTPS connections. }
ServerCfg holds configuration data for the HTTP server. This structure includes details such as the server's domain, subdomains, and port numbers for both HTTP and HTTPS connections.