mirror of https://github.com/statping/statping
http headers for service
parent
bc86b0e515
commit
3eb1cb5805
|
@ -161,10 +161,18 @@ func (s *Service) checkHttp(record bool) *Service {
|
||||||
timeout := time.Duration(s.Timeout) * time.Second
|
timeout := time.Duration(s.Timeout) * time.Second
|
||||||
var content []byte
|
var content []byte
|
||||||
var res *http.Response
|
var res *http.Response
|
||||||
if s.Method == "POST" {
|
|
||||||
content, res, err = utils.HttpRequest(s.Domain, s.Method, "application/json", nil, bytes.NewBuffer([]byte(s.PostData.String)), timeout)
|
var headers []string
|
||||||
|
if s.Headers.Valid {
|
||||||
|
headers = strings.Split(s.Headers.String, ",")
|
||||||
} else {
|
} else {
|
||||||
content, res, err = utils.HttpRequest(s.Domain, s.Method, nil, nil, nil, timeout)
|
headers = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.Method == "POST" {
|
||||||
|
content, res, err = utils.HttpRequest(s.Domain, s.Method, "application/json", headers, bytes.NewBuffer([]byte(s.PostData.String)), timeout)
|
||||||
|
} else {
|
||||||
|
content, res, err = utils.HttpRequest(s.Domain, s.Method, nil, headers, nil, timeout)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if record {
|
if record {
|
||||||
|
|
|
@ -99,7 +99,7 @@ func SelectAllUsers() ([]*User, error) {
|
||||||
func AuthUser(username, password string) (*User, bool) {
|
func AuthUser(username, password string) (*User, bool) {
|
||||||
user, err := SelectUsername(username)
|
user, err := SelectUsername(username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Log(2, err)
|
utils.Log(2, fmt.Errorf("user %v not found", username))
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
if CheckHash(password, user.Password) {
|
if CheckHash(password, user.Password) {
|
||||||
|
|
|
@ -31,7 +31,8 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
|
func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
health := map[string]interface{}{
|
health := map[string]interface{}{
|
||||||
"services": len(core.Services()),
|
"services": len(core.Services()),
|
||||||
"online": core.Configs != nil,
|
"online": true,
|
||||||
|
"setup": core.Configs != nil,
|
||||||
}
|
}
|
||||||
returnJson(health, w, r)
|
returnJson(health, w, r)
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,13 @@
|
||||||
<small class="form-text text-muted">Insert a JSON string to send data to the endpoint.</small>
|
<small class="form-text text-muted">Insert a JSON string to send data to the endpoint.</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group row{{if (eq .Type "tcp") or (eq .Type "udp")}} d-none{{end}}">
|
||||||
|
<label for="headers" class="col-sm-4 col-form-label">HTTP Headers</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="headers" class="form-control" id="headers" autocapitalize="none" spellcheck="false" placeholder='Authorization=1010101,Content-Type=application/json' value="{{.Headers.String}}">
|
||||||
|
<small class="form-text text-muted">Comma delimited list of HTTP Headers</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group row{{if (eq .Type "tcp") or (eq .Type "udp")}} d-none{{end}}">
|
<div class="form-group row{{if (eq .Type "tcp") or (eq .Type "udp")}} d-none{{end}}">
|
||||||
<label for="service_response" class="col-sm-4 col-form-label">Expected Response (Regex)</label>
|
<label for="service_response" class="col-sm-4 col-form-label">Expected Response (Regex)</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -36,6 +36,7 @@ type Service struct {
|
||||||
AllowNotifications NullBool `gorm:"default:true;column:allow_notifications" json:"allow_notifications"`
|
AllowNotifications NullBool `gorm:"default:true;column:allow_notifications" json:"allow_notifications"`
|
||||||
Public NullBool `gorm:"default:true;column:public" json:"public"`
|
Public NullBool `gorm:"default:true;column:public" json:"public"`
|
||||||
GroupId int `gorm:"default:0;column:group_id" json:"group_id"`
|
GroupId int `gorm:"default:0;column:group_id" json:"group_id"`
|
||||||
|
Headers NullString `gorm:"column:headers" json:"headers"`
|
||||||
Permalink NullString `gorm:"column:permalink" json:"permalink"`
|
Permalink NullString `gorm:"column:permalink" json:"permalink"`
|
||||||
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
|
CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
|
||||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.80.51
|
0.80.52
|
||||||
|
|
Loading…
Reference in New Issue