summaryrefslogtreecommitdiff
path: root/src/state.go
diff options
context:
space:
mode:
authorJeroen Wijenbergh <jeroenwijenbergh@protonmail.com>2022-03-07 15:43:07 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-04-05 12:26:13 +0200
commit56548c511163b4dd22d9a96a2f5ae647f1627a7b (patch)
tree20ebfa8641840cd09e026a960e1eca6b60976381 /src/state.go
parentb2228bda5528ad69d0d915e4dc9a15e2291818c8 (diff)
Refactor: Simplify API by using a state as context
Diffstat (limited to 'src/state.go')
-rw-r--r--src/state.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/state.go b/src/state.go
new file mode 100644
index 0000000..a03733a
--- /dev/null
+++ b/src/state.go
@@ -0,0 +1,24 @@
+package eduvpn
+
+type EduVPNState struct {
+ // The struct used for oauth
+ OAuth *EduVPNOauth
+
+ // The endpoints
+ Endpoints *EduVPNEndpoints
+
+ // Info passed by the client
+ Name string
+ Server string
+}
+
+func Register(name string, server string) *EduVPNState {
+ state := &EduVPNState{Name: name, Server: server}
+ endpoints, err := APIGetEndpoints(state)
+
+ if err != nil {
+ panic(err)
+ }
+ state.Endpoints = endpoints
+ return state
+}