Repository navigation
Expand file tree
/
Copy pathproblem_helpers.go
More file actions
94 lines (79 loc) · 2.94 KB
/
Copy pathproblem_helpers.go
File metadata and controls
94 lines (79 loc) · 2.94 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package httpsuite
import "net/http"
// ProblemBadRequest returns a bad request problem builder.
func ProblemBadRequest(detail string) *ProblemBuilder {
return Problem(http.StatusBadRequest).
Type(GetProblemTypeURL("bad_request_error")).
Title("Bad Request").
Detail(detail)
}
// ProblemNotFound returns a not found problem builder.
func ProblemNotFound(detail string) *ProblemBuilder {
return Problem(http.StatusNotFound).
Type(GetProblemTypeURL("not_found_error")).
Title("Not Found").
Detail(detail)
}
// ProblemUnauthorized returns an unauthorized problem builder.
func ProblemUnauthorized(detail string) *ProblemBuilder {
return Problem(http.StatusUnauthorized).
Type(GetProblemTypeURL("unauthorized_error")).
Title("Unauthorized").
Detail(detail)
}
// ProblemForbidden returns a forbidden problem builder.
func ProblemForbidden(detail string) *ProblemBuilder {
return Problem(http.StatusForbidden).
Type(GetProblemTypeURL("forbidden_error")).
Title("Forbidden").
Detail(detail)
}
// ProblemConflict returns a conflict problem builder.
func ProblemConflict(detail string) *ProblemBuilder {
return Problem(http.StatusConflict).
Type(GetProblemTypeURL("conflict_error")).
Title("Conflict").
Detail(detail)
}
// ProblemUnprocessable returns an unprocessable entity problem builder.
func ProblemUnprocessable(detail string) *ProblemBuilder {
return Problem(http.StatusUnprocessableEntity).
Type(GetProblemTypeURL("unprocessable_error")).
Title("Unprocessable Entity").
Detail(detail)
}
// ProblemInternal returns an internal server error problem builder.
func ProblemInternal(detail string) *ProblemBuilder {
return Problem(http.StatusInternalServerError).
Type(GetProblemTypeURL("server_error")).
Title("Internal Server Error").
Detail(detail)
}
// NewBadRequestProblem returns a ready-to-use bad request problem.
func NewBadRequestProblem(detail string) *ProblemDetails {
return ProblemBadRequest(detail).Build()
}
// NewNotFoundProblem returns a ready-to-use not found problem.
func NewNotFoundProblem(detail string) *ProblemDetails {
return ProblemNotFound(detail).Build()
}
// NewUnauthorizedProblem returns a ready-to-use unauthorized problem.
func NewUnauthorizedProblem(detail string) *ProblemDetails {
return ProblemUnauthorized(detail).Build()
}
// NewForbiddenProblem returns a ready-to-use forbidden problem.
func NewForbiddenProblem(detail string) *ProblemDetails {
return ProblemForbidden(detail).Build()
}
// NewConflictProblem returns a ready-to-use conflict problem.
func NewConflictProblem(detail string) *ProblemDetails {
return ProblemConflict(detail).Build()
}
// NewUnprocessableProblem returns a ready-to-use unprocessable entity problem.
func NewUnprocessableProblem(detail string) *ProblemDetails {
return ProblemUnprocessable(detail).Build()
}
// NewInternalProblem returns a ready-to-use internal server error problem.
func NewInternalProblem(detail string) *ProblemDetails {
return ProblemInternal(detail).Build()
}