diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2023-04-12 22:52:49 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2023-09-25 09:43:37 +0200 |
| commit | a23c3e61c5d89ef67973891b5b3a176c06e1b174 (patch) | |
| tree | f1eed03b047f8affd3d5123fa5c9e868ac7d8bec /internal/server/custom/custom.go | |
| parent | ee95eb45708e1fa766a63866d26d05d13f23e8c9 (diff) | |
Refactor: Split internal server into multiple packages
- Pass contexts
- Have separate packages for e.g. custom, institute and secure
- internet servers, profiles....
- Return types from the public ./types package with a Public() method
Diffstat (limited to 'internal/server/custom/custom.go')
| -rw-r--r-- | internal/server/custom/custom.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/server/custom/custom.go b/internal/server/custom/custom.go new file mode 100644 index 0000000..14a72a5 --- /dev/null +++ b/internal/server/custom/custom.go @@ -0,0 +1,31 @@ +package custom + +import ( + "context" + + "github.com/eduvpn/eduvpn-common/internal/server/api" + "github.com/eduvpn/eduvpn-common/internal/server/base" + "github.com/eduvpn/eduvpn-common/internal/server/institute" + "github.com/eduvpn/eduvpn-common/types/server" +) + +type ( + Server = institute.Server + Servers = institute.Servers +) + +func New(ctx context.Context, url string) (*Server, error) { + b := base.Base{ + URL: url, + DisplayName: map[string]string{"en": url}, + Type: server.TypeCustom, + } + if err := api.Endpoints(ctx, &b); err != nil { + return nil, err + } + API := b.Endpoints.API.V3 + + s := &Server{Basic: b} + s.Auth.Init(url, API.Authorization, API.Token) + return s, nil +} |
