37 lines
665 B
Go
37 lines
665 B
Go
package response
|
|
|
|
import (
|
|
"fmt"
|
|
"lishwist/http/templates"
|
|
"net/http"
|
|
|
|
"github.com/Teajey/rsvp"
|
|
)
|
|
|
|
func NotFound() rsvp.Response {
|
|
return Error(http.StatusNotFound, "Page not found")
|
|
}
|
|
|
|
type errorProps struct {
|
|
Navbar templates.NavCollapse
|
|
Message string
|
|
}
|
|
|
|
func Error(status int, format string, a ...any) rsvp.Response {
|
|
return rsvp.Response{
|
|
Body: errorProps{
|
|
Message: fmt.Sprintf(format, a...),
|
|
Navbar: templates.DefaultNavCollapse(),
|
|
},
|
|
Status: status,
|
|
TemplateName: "error_page.gotmpl",
|
|
}
|
|
}
|
|
|
|
func Data(templateName string, body any) rsvp.Response {
|
|
return rsvp.Response{
|
|
Body: body,
|
|
TemplateName: templateName,
|
|
}
|
|
}
|