예제 #1
0
// WithStatus writes the specified HTTP Status Code to the Context's ResponseWriter.
//
// If the Always200ParamName parameter is present, it will ignore the httpStatus argument,
// and always write net/http.StatusOK (200).
func (r *GowebHTTPResponder) WithStatus(ctx context.Context, httpStatus int) error {

	// check for always200
	if len(ctx.FormValue(Always200ParamName)) > 0 {
		// always return OK
		httpStatus = http.StatusOK
	}

	ctx.HttpResponseWriter().WriteHeader(httpStatus)
	return nil
}