You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.0 KiB
48 lines
1.0 KiB
package main |
|
|
|
import ( |
|
"net/http" |
|
|
|
"github.com/gin-gonic/gin" |
|
) |
|
|
|
func showIndexPage(c *gin.Context) { |
|
reminders, _ := getAllReminds() |
|
|
|
// Вызовем метод HTML из Контекста Gin для обработки шаблона |
|
c.HTML( |
|
// Зададим HTTP статус 200 (OK) |
|
http.StatusOK, |
|
// Используем шаблон index.html |
|
"index.html", |
|
// Передадим данные в шаблон |
|
gin.H{ |
|
"title": "Home Page", |
|
"payload": reminders, |
|
}, |
|
) |
|
|
|
} |
|
|
|
func showOneRemind(c *gin.Context) { |
|
var remind Remind |
|
if err := DB.Where("id = ?", c.Param("id")).First(&remind).Error; err != nil { |
|
c.HTML(http.StatusBadRequest, "404.html", gin.H{"title": "Error", "error": "Record not found!"}) |
|
return |
|
} |
|
|
|
c.HTML( |
|
// Зададим HTTP статус 200 (OK) |
|
http.StatusOK, |
|
// Используем шаблон index.html |
|
"remind.view.html", |
|
// Передадим данные в шаблон |
|
gin.H{ |
|
"title": "View remind", |
|
"payload": remind, |
|
}, |
|
) |
|
|
|
} |
|
|
|
func createOneRemind(c *gin.Context) {}
|
|
|