go-mcm/mcm.go

36 lines
594 B
Go

package mcm
import (
"fmt"
"strings"
"git.canopymc.net/Etzelia/go-mcm/model"
"git.canopymc.net/Etzelia/go-mcm/web"
)
type MCM struct {
Token string
URL string
}
func NewMCM(token, baseURL string) *MCM {
return &MCM{
Token: token,
URL: strings.TrimRight(baseURL, "/"),
}
}
func (mcm *MCM) NewModel() *model.Model {
return &model.Model{
Token: mcm.Token,
URL: fmt.Sprintf("%s/model", strings.TrimRight(mcm.URL, "/")),
}
}
func (mcm *MCM) NewWeb() *web.Web {
return &web.Web{
Token: mcm.Token,
URL: fmt.Sprintf("%s/web", strings.TrimRight(mcm.URL, "/")),
}
}