TypeCore

Request

The Request type represents an HTTP request with methods for accessing request data.

Type Definition

type Request struct {
    Conn          net.Conn
    Method        string
    Path          string
    Body          io.ReadCloser
    Headers       map[string]string
    Url           *url.URL
    Params        map[string]string
    ContentLength int64
    Close         bool
    Queries       map[string][]string
    Cookies       []*cookies.Cookie
}

Methods

ReadBodyAsString()

Reads the request body and returns it as a string.

func (r *Request) ReadBodyAsString() (string, error)

Param()

Retrieves a URL parameter by name from route patterns like /users/:id.

func (r *Request) Param(paramName string) string

Query()

Retrieves query parameters from the URL. Supports multi-value query parameters.

func (r *Request) Query() []string

GetCookie()

Gets a cookie by its name from the request.

func (r *Request) GetCookie(name string) *cookies.Cookie

OriginalUrl()

Retrieves the original URL of the incoming request.

func (r *Request) OriginalUrl() *url.URL