mirror of
https://github.com/mpolden/echoip.git
synced 2025-07-15 13:33:31 +02:00
api: add /test for testing ip reachability
This commit is contained in:
17
api/error.go
17
api/error.go
@ -1,6 +1,14 @@
|
||||
package api
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
var (
|
||||
errBadRequest = newAppError(http.StatusBadRequest)
|
||||
errGone = newAppError(http.StatusGone)
|
||||
)
|
||||
|
||||
type appError struct {
|
||||
Error error
|
||||
@ -9,6 +17,13 @@ type appError struct {
|
||||
ContentType string
|
||||
}
|
||||
|
||||
func newAppError(code int) *appError {
|
||||
return &appError{
|
||||
Error: errors.New(http.StatusText(code)),
|
||||
Code: code,
|
||||
}
|
||||
}
|
||||
|
||||
func internalServerError(err error) *appError {
|
||||
return &appError{Error: err, Response: "Internal server error", Code: http.StatusInternalServerError}
|
||||
}
|
||||
|
Reference in New Issue
Block a user