go-mcm/mcm.go

35 lines
573 B
Go
Raw Normal View History

2019-10-03 20:22:22 +00:00
package mcm
import (
"fmt"
"go.etztech.xyz/go-mcm/model"
"go.etztech.xyz/go-mcm/web"
"strings"
)
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, "/")),
}
}