Documentation ¶
Index ¶
- func ExternalIP() (string, error)
- func IsNotFound(err error) bool
- func RequiredValue(value string, envname string, defaultvalue string) (s string)
- func WriteError(rw http.ResponseWriter, code string, err error)
- func WriteJSON(rw http.ResponseWriter, j interface{})
- func WriteJSONPretty(rw http.ResponseWriter, j interface{})
- func WriteNewWebError(rw http.ResponseWriter, code int, errorcode string, msg string)
- func WriteWebError(rw http.ResponseWriter, we *WebError)
- type WebError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNotFound ¶
tests if an error was a WebError with http.NotFound OR a mongo error string of not found
func RequiredValue ¶
returns either the value passed in, the value of the environment string specified, or the default. If the result of all of that is blank, panics.
func WriteError ¶
func WriteError(rw http.ResponseWriter, code string, err error)
WriteError writes any kind of error If it's a Web error, it defers to that and ignores the code passed in. If it's any other kind of error, it builds a new WebError for an InternalServerError (500) with the given code.
If you're calling this, it's because you expect that the call wasn't going to fail unless there was some system problem.
func WriteJSON ¶
func WriteJSON(rw http.ResponseWriter, j interface{})
func WriteJSONPretty ¶
func WriteJSONPretty(rw http.ResponseWriter, j interface{})
func WriteNewWebError ¶
func WriteNewWebError(rw http.ResponseWriter, code int, errorcode string, msg string)
func WriteWebError ¶
func WriteWebError(rw http.ResponseWriter, we *WebError)
Types ¶
type WebError ¶
type WebError struct { Code int ErrorCode string // should be unique across all our packages Msg string Detail map[string]string }
func (WebError) GetJSON ¶
DEPRECATED -- after the next deploy of tagserver, this function will no longer be called anywhere and should be deleted.