mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 08:16:39 +00:00
fix: minor HTTP bugs
This commit is contained in:
@@ -58,6 +58,7 @@ func (h *Peers) deletePeer(accountId string, peer *server.Peer, w http.ResponseW
|
||||
http.Redirect(w, r, "/", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
writeJSONObject(w, "")
|
||||
}
|
||||
|
||||
func (h *Peers) HandlePeer(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -27,6 +27,7 @@ type SetupKeyResponse struct {
|
||||
Revoked bool
|
||||
UsedTimes int
|
||||
LastUsed time.Time
|
||||
State string
|
||||
}
|
||||
|
||||
// SetupKeyRequest is a request sent by client. This object contains fields that can be modified
|
||||
@@ -183,6 +184,16 @@ func writeSuccess(w http.ResponseWriter, key *server.SetupKey) {
|
||||
}
|
||||
|
||||
func toResponseBody(key *server.SetupKey) *SetupKeyResponse {
|
||||
var state string
|
||||
if key.IsExpired() {
|
||||
state = "expired"
|
||||
} else if key.IsRevoked() {
|
||||
state = "revoked"
|
||||
} else if key.IsOverUsed() {
|
||||
state = "overused"
|
||||
} else {
|
||||
state = "valid"
|
||||
}
|
||||
return &SetupKeyResponse{
|
||||
Id: key.Id,
|
||||
Key: key.Key,
|
||||
@@ -193,5 +204,6 @@ func toResponseBody(key *server.SetupKey) *SetupKeyResponse {
|
||||
Revoked: key.Revoked,
|
||||
UsedTimes: key.UsedTimes,
|
||||
LastUsed: key.LastUsed,
|
||||
State: state,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user