Documentation
¶
Index ¶
- func Default() core.Application
- func New(opts ...Option) core.Application
- type Application
- type Option
- type Request
- func (req *Request) Body() (io.ReadCloser, error)
- func (req *Request) ClientIP() string
- func (req *Request) ContentLength() int64
- func (req *Request) Context() context.Context
- func (req *Request) Cookie(name string) (*http.Cookie, error)
- func (req *Request) Cookies() []*http.Cookie
- func (req *Request) Header(name string) string
- func (req *Request) HeaderValues(name string) []string
- func (req *Request) Headers() http.Header
- func (req *Request) Method() string
- func (req *Request) Path() string
- func (req *Request) PathValue(name string) string
- func (req *Request) Protocol() string
- func (req *Request) Queries() url.Values
- func (req *Request) Query(name string) string
- func (req *Request) QueryValues(name string) []string
- func (req *Request) Request() any
- func (req *Request) Resource() string
- func (req *Request) SetPathValue(name, value string)
- func (req *Request) SetResource(resource string)
- type Response
- func (resp *Response) AddHeader(key, value string)
- func (resp *Response) DelHeader(key string)
- func (resp *Response) GetHeader(key string) string
- func (resp *Response) Headers() http.Header
- func (resp *Response) Response() any
- func (resp *Response) SetHeader(key, value string)
- func (resp *Response) Status(code int)
- func (resp *Response) StatusCode() int
- func (resp *Response) Write(data []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
func Default() core.Application
Default returns a default application instance with default settings.
func New ¶
func New(opts ...Option) core.Application
New returns a new application instance with default settings. It allows for further customization before starting the server.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application is an HTTP web application to serve HTTP requests.
func (*Application) ServeHTTP ¶
func (app *Application) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements the http.Handler interface to handle incoming HTTP requests.
func (*Application) Shutdown ¶
func (app *Application) Shutdown(ctx context.Context) error
Shutdown gracefully shuts down the application server.
func (*Application) Start ¶
func (app *Application) Start() error
Start starts the application server and listens for incoming requests. It returns an error if it fails to start.
func (*Application) Use ¶
func (app *Application) Use(handlers ...core.HandlerFunc) core.Application
Use adds the given handlers to the application.
type Option ¶
type Option func(*Application)
Option is a function that configures the Application.
func WithAddress ¶
WithAddress sets the address for the application server to listen on.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request represents an HTTP request received by the application.
func (*Request) Body ¶
func (req *Request) Body() (io.ReadCloser, error)
Body returns the request body as a readable stream.
func (*Request) ContentLength ¶
ContentLength returns the length of the request body in bytes. If the length is unknown, it returns -1.
func (*Request) Header ¶
Header returns the value of the specified header field from the request. If the header is not present, it returns an empty string.
func (*Request) HeaderValues ¶
HeaderValues returns all values associated with the specified header field from the request. If the header is not present, it returns an empty slice.
func (*Request) PathValue ¶
PathValue returns the value of the specified path parameter from the request. If the parameter is not present, it returns an empty string.
func (*Request) Protocol ¶
Protocol returns the HTTP protocol version used in the request (e.g., HTTP/1.1, HTTP/2, etc.).
func (*Request) Queries ¶
Queries returns all query parameters from the request URL as a url.Values map, where the keys are the parameter names and the values are slices of parameter values. If there are no query parameters, it returns an empty map.
func (*Request) Query ¶
Query returns the value of the specified query parameter from the request URL. If the parameter is not present, it returns an empty string.
func (*Request) QueryValues ¶
QueryValues returns all values associated with the specified query parameter from the request URL. If the parameter is not present, it returns an empty slice.
func (*Request) Request ¶
Request returns the underlying http.Request associated with this Request. This can be used to access any additional information or functionality provided by the http.Request that is not exposed through the Request interface.
func (*Request) Resource ¶
Resource returns the resource associated with the request. The resource is a string that can be used to identify the type of request or the endpoint being accessed. It is typically set by the router based on the URL pattern matched for the request.
func (*Request) SetPathValue ¶
SetPathValue sets the value of the specified path parameter in the request. This is typically used by the router to store path parameters extracted from the URL.
func (*Request) SetResource ¶
SetResource sets the resource associated with the request. This is typically used by the router to store the resource identifier based on the URL pattern matched for the request.
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func (*Response) AddHeader ¶
AddHeader adds a header field with the specified key and value to the response. If the header field already exists, the new value will be appended to the existing values for that header.
func (*Response) DelHeader ¶
DelHeader deletes the specified header field from the response. If the header field is not present, this method does nothing.
func (*Response) GetHeader ¶
GetHeader returns the value of the specified header field from the response. If the header field is not present, it returns an empty string.
func (*Response) Headers ¶
Headers returns the http.Header map containing all the header fields and their values in the response. This allows you to access and manipulate the headers of the response as needed before sending it back to the client.
func (*Response) Response ¶
Response returns the underlying http.ResponseWriter associated with this Response. This can be used to access any additional information or functionality provided by the http.ResponseWriter that is not exposed through the Response interface.
Note: Do not manipulate the returned http.ResponseWriter directly, as it may interfere with the proper handling of the response by the framework. Use the methods provided by the Response interface to manipulate the response instead.
func (*Response) SetHeader ¶
SetHeader sets a header field with the specified key and value in the response. If the header field already exists, its value will be replaced with the new value.
func (*Response) Status ¶
Status sets the HTTP status code for the response. This method allows you to specify the status code that should be sent back to the client along with the response. If you do not set a status code, the default status code of 200 OK will be used when the response is sent.
func (*Response) StatusCode ¶
StatusCode returns the HTTP status code that has been set for the response. If no status code has been set, it returns 0, which indicates that the default status code of 200 OK will be used when the response is sent.