Files
gluetun/internal/server/wrappers.go

35 lines
719 B
Go
Raw Normal View History

package server
import (
2021-05-30 16:14:08 +00:00
"errors"
"fmt"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/models"
)
type statusWrapper struct {
Status string `json:"status"`
}
2021-05-30 16:14:08 +00:00
var errInvalidStatus = errors.New("invalid status")
func (sw *statusWrapper) getStatus() (status models.LoopStatus, err error) {
status = models.LoopStatus(sw.Status)
switch status {
case constants.Stopped, constants.Running:
return status, nil
default:
2021-05-30 16:14:08 +00:00
return "", fmt.Errorf("%w: %s: possible values are: %s, %s",
errInvalidStatus, sw.Status, constants.Stopped, constants.Running)
}
}
type portWrapper struct {
Port uint16 `json:"port"`
}
type outcomeWrapper struct {
Outcome string `json:"outcome"`
}