api: add /test for testing ip reachability

This commit is contained in:
Rafal Jeczalik
2016-03-03 15:03:47 +01:00
parent f70690f4b4
commit 5e5e9c07cd
3 changed files with 84 additions and 1 deletions

View File

@ -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}
}