HTTP Requests
[[toc]]
Introduction
The contracts/http/Request
method of Goravel can interact with the current HTTP request processed by the application, and get the input and files submitted together.
Interacting With The Request
The http.Context
instance is automatically injected into the controller:
Retrieving The Request Path
Retrieving The Request URL
Retrieving The Request HOST
Retrieving The Full Request URL
Retrieving The Request Method
Request Headers
Request IP Address
Input
Retrieving All Input Data
You may retrieve all of the incoming request's input data as map[string]any
using the All
method, is a collection of json
, form
and query
(priority from front to back).
Retrieving An Route Value
Retrieving Input From The Query String
Retrieving Form
Retrieving Json
Note: Only one-dimensional Json data can be obtained, otherwise it will return empty.
Retrieving An Input Value
Access all of the user input without worrying about which HTTP verb was used for the request. Retrieve order: json
, form
, query
, route
.
Json/Form Bind Struct
File
Retrieving File
Save File
Abort Request
Get Origin Request
Attach Data
Get Data
Get Context
Last updated