Golang net/http.StatusText() function example
package net/http
Golang net/http.StatusText() function usage example
package main
import (
"fmt"
"net/http"
)
func main() {
statusStr := http.StatusText(400)
fmt.Println(statusStr)
statusStr = http.StatusText(200)
fmt.Println(statusStr)
}
Output :
Bad Request
OK
References :
http://golang.org/pkg/net/http/#StatusText
// HTTP status codes, defined in RFC 2616.
StatusContinue = 100
StatusSwitchingProtocols = 101
StatusOK = 200
StatusCreated = 201
StatusAccepted = 202
StatusNonAuthoritativeInfo = 203
StatusNoContent = 204
StatusResetContent = 205
StatusPartialContent = 206
StatusMultipleChoices = 300
StatusMovedPermanently = 301
StatusFound = 302
StatusSeeOther = 303
StatusNotModified = 304
StatusUseProxy = 305
StatusTemporaryRedirect = 307
StatusBadRequest = 400
StatusUnauthorized = 401
StatusPaymentRequired = 402
StatusForbidden = 403
StatusNotFound = 404
StatusMethodNotAllowed = 405
StatusNotAcceptable = 406
StatusProxyAuthRequired = 407
StatusRequestTimeout = 408
StatusConflict = 409
StatusGone = 410
StatusLengthRequired = 411
StatusPreconditionFailed = 412
StatusRequestEntityTooLarge = 413
StatusRequestURITooLong = 414
StatusUnsupportedMediaType = 415
StatusRequestedRangeNotSatisfiable = 416
StatusExpectationFailed = 417
StatusTeapot = 418 StatusInternalServerError = 500
StatusNotImplemented = 501
StatusBadGateway = 502
StatusServiceUnavailable = 503
StatusGatewayTimeout = 504
StatusHTTPVersionNotSupported = 505
// New HTTP status codes from RFC 6585. Not exported yet in Go 1.1.
// See discussion at https://codereview.appspot.com/7678043/
statusPreconditionRequired = 428
statusTooManyRequests = 429
statusRequestHeaderFieldsTooLarge = 431
statusNetworkAuthenticationRequired = 511
Advertisement
Something interesting
Tutorials
+3.7k Java : Random alphabets, alpha-numeric or numbers only string generator
+6.5k Elasticsearch : Shutdown a local node
+13.4k Golang : error parsing regexp: invalid or unsupported Perl syntax
+5.9k Facebook : How to force facebook to scrape latest URL link data?
+25.2k Golang : Storing cookies in http.CookieJar example
+6.1k nginx : force all pages to be SSL
+12.3k Golang : How to display image file or expose CSS, JS files from localhost?
+25.6k Golang : convert rune to integer value
+31.9k Golang : Convert an image file to []byte
+5.1k Linux/Unix/MacOSX : Find out which application is listening to port 80 or use which IP version
+11.9k Golang : Convert decimal number(integer) to IPv4 address