github.com/astaxie/beego@v1.12.3/context/response.go (about)

     1  package context
     2  
     3  import (
     4  	"strconv"
     5  
     6  	"net/http"
     7  )
     8  
     9  const (
    10  	//BadRequest indicates http error 400
    11  	BadRequest StatusCode = http.StatusBadRequest
    12  
    13  	//NotFound indicates http error 404
    14  	NotFound StatusCode = http.StatusNotFound
    15  )
    16  
    17  // StatusCode sets the http response status code
    18  type StatusCode int
    19  
    20  func (s StatusCode) Error() string {
    21  	return strconv.Itoa(int(s))
    22  }
    23  
    24  // Render sets the http status code
    25  func (s StatusCode) Render(ctx *Context) {
    26  	ctx.Output.SetStatus(int(s))
    27  }