chore(tfstated): refactor helpers to their own package
This commit is contained in:
parent
5b6da56089
commit
25ed1188ed
11 changed files with 78 additions and 62 deletions
17
pkg/helpers/error.go
Normal file
17
pkg/helpers/error.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package helpers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func ErrorResponse(w http.ResponseWriter, status int, err error) {
|
||||
type errorResponse struct {
|
||||
Msg string `json:"msg"`
|
||||
Status int `json:"status"`
|
||||
}
|
||||
_ = Encode(w, status, &errorResponse{
|
||||
Msg: fmt.Sprintf("%+v", err),
|
||||
Status: status,
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue