Respond #
IMPORTANT!
The response file should be placed in directoryapp/http/response
How to response string
, HTML
, JSON
, download
data
Response error
#
// Simple
return errors.NotYetImplemented
// Structure JSON
return c.Error(response.Error{
Message: err.Error(),
Code: gfly.StatusBadRequest,
})
Response string
, HTML
#
// String
return c.String("Hello world")
// HTML
return c.HTML("<h2>Hello world</h2>")
Response JSON
#
return c.Status(gfly.StatusOK).JSON(response.SignIn{
Access: tokens.Access,
Refresh: tokens.Refresh,
})
Response download
#
return c.Download("./storage/logs/logs.log", "Log_file.log")