mirror of
https://github.com/openziti/zrok.git
synced 2025-01-22 13:58:49 +01:00
refactoring around the new sdk approach (#34)
This commit is contained in:
parent
29b87571cb
commit
917ba12ce6
23
sdk/model.go
Normal file
23
sdk/model.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package sdk
|
||||||
|
|
||||||
|
type BackendMode string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ProxyBackendMode BackendMode = "proxy"
|
||||||
|
WebBackendMode BackendMode = "web"
|
||||||
|
TcpTunnelBackendMode BackendMode = "tcpTunnel"
|
||||||
|
UdpTunnelBackendMode BackendMode = "udpTunnel"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ShareMode string
|
||||||
|
|
||||||
|
const (
|
||||||
|
PrivateShareMode ShareMode = "private"
|
||||||
|
PublicShareMode ShareMode = "public"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ShareRequest struct {
|
||||||
|
BackendMode BackendMode
|
||||||
|
ShareMode ShareMode
|
||||||
|
Target string
|
||||||
|
}
|
42
sdk/share.go
Normal file
42
sdk/share.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package sdk
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/openziti/zrok/rest_model_zrok"
|
||||||
|
"github.com/openziti/zrok/zrokdir"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Share struct {
|
||||||
|
Token string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewShare(request *ShareRequest) (*Share, error) {
|
||||||
|
switch request.ShareMode {
|
||||||
|
case PrivateShareMode:
|
||||||
|
return newPrivateShare(request)
|
||||||
|
case PublicShareMode:
|
||||||
|
return newPublicShare(request)
|
||||||
|
default:
|
||||||
|
return nil, errors.Errorf("unknown share mode '%v'", request.ShareMode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPrivateShare(request *ShareRequest) (*Share, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPublicShare(request *ShareRequest) (*Share, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadEnvironment(request *ShareRequest) (*zrokdir.ZrokDir, error) {
|
||||||
|
zrd, err := zrokdir.Load()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "error loading zrokdir")
|
||||||
|
}
|
||||||
|
return zrd, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func createShare(zrd *zrokdir.ZrokDir, req *rest_model_zrok.ShareRequest) (*Share, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user