Skip to main content

Response

Below are the different types of responses you can return to the user

Return JSON

func SomeHandler(c *core.Context) {
return c.Response.Json(myJson)
}

Return HTML

func SomeHandler(c *core.Context) {
return c.Response.HTML(myHTML)
}

Return Text

func SomeHandler(c *core.Context) {
return c.Response.Text(myText)
}

Return Any response

func SomeHandler(c *core.Context) {
return c.Response.Any(anyResponse)
}

Set response headers

func SomeHandler(c *core.Context) {
return c.Response.SetHeader("key", "value").Json(myJson)
}

Set response content type

func SomeHandler(c *core.Context) {
return c.Response.SetContentType("application/json").any(myJson)
}

Set response status code

func SomeHandler(c *core.Context) {
return c.Response.SetStatusCode(400).Json(myJson)
}