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
+13.4k Golang : Verify token from Google Authenticator App
+13.6k Golang : Qt progress dialog example
+20k Golang : How to run your code only once with sync.Once object
+9.4k Golang : Web(Javascript) to server-side websocket example
+25.3k Golang : Convert uint value to string type
+11.1k Golang : Read until certain character to break for loop
+8.1k Golang : Randomize letters from a string example
+21.6k Golang : GORM create record or insert new record into database example
+5.7k Golang : Struct field tags and what is their purpose?
+9.9k Golang : Sort and reverse sort a slice of integers
+5.8k Golang : Markov chains to predict probability of next state example
+15.6k Golang : How to convert(cast) IP address to string?