mirror of https://github.com/statping/statping
Fixed type errors
parent
087a333947
commit
fc89bcdd31
|
@ -3,13 +3,14 @@ package handlers
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/statping/statping/types/errors"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/statping/statping/source"
|
"github.com/statping/statping/source"
|
||||||
|
"github.com/statping/statping/types/errors"
|
||||||
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -212,13 +213,14 @@ func returnJson(d interface{}, w http.ResponseWriter, r *http.Request) {
|
||||||
json.NewEncoder(w).Encode(d)
|
json.NewEncoder(w).Encode(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func returnResponseCode(s *Service, w http.ResponseWriter, r *http.Request) {
|
func returnResponseCode(s *services.Service, w http.ResponseWriter, r *http.Request) {
|
||||||
// Go does not currently
|
// Go does not currently
|
||||||
// support sending user-defined 1xx informational headers,
|
// support sending user-defined 1xx informational headers,
|
||||||
// with the exception of 100-continue response header that the
|
// with the exception of 100-continue response header that the
|
||||||
// Server sends automatically when the Request.Body is read.
|
// Server sends automatically when the Request.Body is read.
|
||||||
// https://golang.org/src/net/http/server.go?s=3003:5866#L150
|
// https://golang.org/src/net/http/server.go?s=3003:5866#L150
|
||||||
if LastStatusCode >= 100 {
|
|
||||||
|
if s.LastStatusCode >= 100 {
|
||||||
w.WriteHeader(s.LastStatusCode)
|
w.WriteHeader(s.LastStatusCode)
|
||||||
w.Write([]byte(s.DownText))
|
w.Write([]byte(s.DownText))
|
||||||
return
|
return
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/statping/statping/database"
|
"github.com/statping/statping/database"
|
||||||
"github.com/statping/statping/types/errors"
|
"github.com/statping/statping/types/errors"
|
||||||
|
@ -8,7 +10,6 @@ import (
|
||||||
"github.com/statping/statping/types/hits"
|
"github.com/statping/statping/types/hits"
|
||||||
"github.com/statping/statping/types/services"
|
"github.com/statping/statping/types/services"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
"net/http"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type serviceOrder struct {
|
type serviceOrder struct {
|
||||||
|
@ -317,12 +318,13 @@ func apiServiceHitsHandler(r *http.Request) interface{} {
|
||||||
return hts
|
return hts
|
||||||
}
|
}
|
||||||
|
|
||||||
func apiServiceResponseCodeHandler(w http.ResponseWriter, r *http.Request) interface{} {
|
func apiServiceResponseCodeHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
service, err := findService(r)
|
service, err := findService(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
sendErrorJson(err, w, r)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return returnResponseCode(service, w, r)
|
returnResponseCode(service, w, r)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue