Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions render.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"encoding/xml"
"fmt"
"html/template"
"io"
"io"
"io/ioutil"
"net/http"
"os"
Expand Down Expand Up @@ -92,6 +92,8 @@ type Render interface {
Error(status int)
// Status is an alias for Error (writes an http status to the http.ResponseWriter)
Status(status int)
// StatusText is the same as Status except it allows you to customise the error text.
StatusText(status int, text string)
// Redirect is a convienience function that sends an HTTP redirect. If status is omitted, uses 302 (Found)
Redirect(location string, status ...int)
// Template returns the internal *template.Template used to render the HTML
Expand Down Expand Up @@ -325,11 +327,16 @@ func (r *renderer) Data(status int, v []byte) {

// Error writes the given HTTP status to the current ResponseWriter
func (r *renderer) Error(status int) {
r.WriteHeader(status)
r.Status(status)
}

func (r *renderer) Status(status int) {
r.StatusText(status, http.StatusText(status))
}

func (r *renderer) StatusText(status int, text string) {
r.WriteHeader(status)
fmt.Fprint(r, status, " ", text)
}

func (r *renderer) Redirect(location string, status ...int) {
Expand Down