-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.go
More file actions
27 lines (27 loc) · 799 Bytes
/
doc.go
File metadata and controls
27 lines (27 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Package statuserr provides errors with a HTTP status code.
// this is useful for writing HTTP APIs.
// return http status from any part of the codebase
// _, Err := ioutil.ReadAll(r)
// if Err != nil {
// return statusErr.InternalServerError.Wrap(Err)
// }
//
// other possible uses
// if user != "stark" {
// return statusErr.NotImplemented.Msgf("service does not work for %s", user)
// }
//
// if one is lazy
// if user.NoName() {
// return statusErr.Conflict
// }
// package has types for all http status codes greater than 400.
// The Error values implement interface
// type StatusCode interface {
// Status() int
// }
// to get the status code do
// if e, ok := Err.(StatusCode); ok {
// http.Error(w, e.Status(), e.Error())
// }
package statuserr