modular backend implementation for share private (#95)

This commit is contained in:
Michael Quigley
2022-12-13 12:24:28 -05:00
parent 67619df5c6
commit ac09f2d749
3 changed files with 73 additions and 42 deletions

View File

@@ -100,15 +100,21 @@ func (h *shareHandler) Handle(params service.ShareParams, principal *rest_model_
logrus.Debugf("allocated service '%v'", svcToken)
reserved := params.Body.Reserved
sid, err := str.CreateService(envId, &store.Service{
ssvc := &store.Service{
ZId: svcZId,
Token: svcToken,
ShareMode: params.Body.ShareMode,
BackendMode: params.Body.BackendMode,
FrontendEndpoint: &frontendEndpoints[0],
BackendProxyEndpoint: &params.Body.BackendProxyEndpoint,
Reserved: reserved,
}, tx)
}
if len(frontendEndpoints) > 0 {
ssvc.FrontendEndpoint = &frontendEndpoints[0]
} else if ssvc.ShareMode == "private" {
ssvc.FrontendEndpoint = &ssvc.ShareMode
}
sid, err := str.CreateService(envId, ssvc, tx)
if err != nil {
logrus.Errorf("error creating service record: %v", err)
return service.NewShareInternalServerError()