Documentation ¶
Index ¶
- Variables
- func GetHost[T RequestConstraint](r T) string
- type JSONResponse
- type Request
- func (r *Request) Error(code int, err string)
- func (r *Request) Form() url.Values
- func (r *Request) FormFileBuffer(name string) (*bytes.Buffer, error)
- func (r *Request) GetData(key string) interface{}
- func (r *Request) IsGet() bool
- func (r *Request) IsPost() bool
- func (r *Request) Method() string
- func (r *Request) SetData(key string, value interface{})
- func (r *Request) Write(b []byte) (int, error)
- func (r *Request) WriteString(s string) (int, error)
- type RequestConstraint
- type ResponseStatus
- type URLParams
- type User
Constants ¶
This section is empty.
Variables ¶
var GetRequestUserFunc = func(w http.ResponseWriter, r *http.Request) User { return nil }
You need to override this function to be able to use the `request.User` field. Function which will be called at the initialization of every request. This function should return a user, to set on the request.
Beware!
- This function is called before any middlewares are called!
Functions ¶
func GetHost ¶
func GetHost[T RequestConstraint](r T) string
Types ¶
type JSONResponse ¶
type JSONResponse struct { Status ResponseStatus `json:"status"` Data interface{} `json:"data"` }
Default json response which gets returned when using (j).Encode().
type Request ¶
type Request struct { Response http.ResponseWriter Request *http.Request Data map[string]interface{} URLParams URLParams User User JSON *_json // contains filtered or unexported fields }
Default request to be passed around the router.
func NewRequest ¶
Initialize a new request.
func (*Request) FormFileBuffer ¶
Get a form file as a buffer.
type RequestConstraint ¶
type ResponseStatus ¶
type ResponseStatus string
const ( ResponseStatusOK ResponseStatus = "ok" ResponseStatusError ResponseStatus = "error" ResponseStatusRedirect ResponseStatus = "redirect" )
type User ¶ added in v2.0.1
type User interface {
IsAuthenticated() bool
}
Default request user interface. This interface is used to check if a user is authenticated. This interface is used by the LoginRequiredMiddleware and LogoutRequiredMiddleware. If you want to use these middlewares, you should implement this interface. And set the GetRequestUserFunc function to return a user.