From 56548c511163b4dd22d9a96a2f5ae647f1627a7b Mon Sep 17 00:00:00 2001 From: Jeroen Wijenbergh Date: Mon, 7 Mar 2022 15:43:07 +0100 Subject: Refactor: Simplify API by using a state as context --- src/state.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/state.go (limited to 'src/state.go') 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 +} -- cgit v1.2.3