lishwist/http/response/response.go

28 lines
498 B
Go

package response
import (
"fmt"
"net/http"
"github.com/Teajey/rsvp"
)
func NotFound() rsvp.Response {
return Error(http.StatusNotFound, "Page not found")
}
func Error(status int, format string, a ...any) rsvp.Response {
return rsvp.Response{
Body: fmt.Sprintf(format, a...),
Status: status,
TemplateName: "error_page.gotmpl",
}
}
func Data(templateName string, body any) rsvp.Response {
return rsvp.Response{
Body: body,
TemplateName: templateName,
}
}