Skip to main content
gFly v1.15.1
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage
Edit page

Responses

Note
IMPORTANT!
The response file should be placed in directory app/http/response

How to response string, HTML, JSON, download data

Response error

// Simple 
return errors.NotImplemented

// Structure JSON
return c.Error(response.Error{
    Code:    core.StatusUnauthorized,
    Message: "Invalid JWT token",
}, core.StatusUnauthorized)

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")

Response View

func (m *UploadFormPage) Handle(c *gfly.Ctx) error {
    return c.View("upload", gfly.ViewData{})
}

View template resources/views/upload.tpl