From 26394d62fef41dd1bd1bd81141e0fd5eb18da418 Mon Sep 17 00:00:00 2001 From: Matan Budimir Date: Thu, 27 Aug 2020 18:35:52 +0200 Subject: [PATCH] Correct package names --- Handle/callback.go | 2 +- Handle/env.go | 10 +++++----- Handle/login.go | 10 +++++----- Handle/structs.go | 2 +- Helpers/check.go | 2 +- Helpers/string.go | 2 +- Layout/generate.go | 2 +- {Example => examples}/example.go | 6 +++--- go.mod | 10 ++++++++++ go.sum | 19 +++++++++++++++++++ main.go | 10 +++++----- 11 files changed, 52 insertions(+), 23 deletions(-) rename {Example => examples}/example.go (86%) create mode 100644 go.mod create mode 100644 go.sum diff --git a/Handle/callback.go b/Handle/callback.go index 653310c..e40ddc0 100644 --- a/Handle/callback.go +++ b/Handle/callback.go @@ -1,4 +1,4 @@ -package Handle +package handle // Connect callback after successful client authentication diff --git a/Handle/env.go b/Handle/env.go index 9ebedcd..3dbfe76 100644 --- a/Handle/env.go +++ b/Handle/env.go @@ -1,8 +1,8 @@ -package Handle +package handle import ( - "connect-go/Helpers" - "connect-go/Layout" + "connect-go/helpers" + "connect-go/layout" "fmt" "net/http" "os" @@ -15,9 +15,9 @@ import ( // If request isn't get it will save sent form func Env(w http.ResponseWriter, r *http.Request) { - if Helpers.CheckData() == true { + if helpers.CheckData() == true { - error := Layout.Generate("", "
" + + error := layout.Generate("", "" + "

Forbidden

" + "
", "") diff --git a/Handle/login.go b/Handle/login.go index bc02745..0518101 100644 --- a/Handle/login.go +++ b/Handle/login.go @@ -1,7 +1,7 @@ -package Handle +package handle import ( - "connect-go/Helpers" + "connect-go/helpers" "fmt" "net/http" "os" @@ -14,15 +14,15 @@ var ( // Login function sends a GET request to connect with entered credentials func Login(w http.ResponseWriter, r *http.Request) { - if Helpers.CheckData() == false { + if helpers.CheckData() == false { http.Redirect(w, r, "/connect/install", http.StatusTemporaryRedirect) } switch os.Getenv("connection") { case "DEV": - link = fmt.Sprintf("https://auth-dev.vatsim.net/oauth/authorize?client_id=%v&redirect_uri=%v&response_type=code&scope=%v&state=%v", os.Getenv("client_id"), os.Getenv("redirect"), os.Getenv("scopes"), Helpers.RandString(40)) + link = fmt.Sprintf("https://auth-dev.vatsim.net/oauth/authorize?client_id=%v&redirect_uri=%v&response_type=code&scope=%v&state=%v", os.Getenv("client_id"), os.Getenv("redirect"), os.Getenv("scopes"), helpers.RandString(40)) case "LIVE": - link = fmt.Sprintf("https://auth.vatsim.net/oauth/authorize?client_id=%v&redirect_uri=%v&response_type=code&scope=%v&state=%v", os.Getenv("client_id"), os.Getenv("redirect"), os.Getenv("scopes"), Helpers.RandString(40)) + link = fmt.Sprintf("https://auth.vatsim.net/oauth/authorize?client_id=%v&redirect_uri=%v&response_type=code&scope=%v&state=%v", os.Getenv("client_id"), os.Getenv("redirect"), os.Getenv("scopes"), helpers.RandString(40)) default: http.Redirect(w, r, "/", http.StatusBadRequest) } diff --git a/Handle/structs.go b/Handle/structs.go index 204a080..5fc1dca 100644 --- a/Handle/structs.go +++ b/Handle/structs.go @@ -1,4 +1,4 @@ -package Handle +package handle // An Access represents access token which we get from AccessToken function type Access struct { diff --git a/Helpers/check.go b/Helpers/check.go index 313dc4c..bb6c45f 100644 --- a/Helpers/check.go +++ b/Helpers/check.go @@ -1,4 +1,4 @@ -package Helpers +package helpers import ( "os" diff --git a/Helpers/string.go b/Helpers/string.go index 516448f..585f3f3 100644 --- a/Helpers/string.go +++ b/Helpers/string.go @@ -1,4 +1,4 @@ -package Helpers +package helpers import ( "math/rand" diff --git a/Layout/generate.go b/Layout/generate.go index cc21659..80348e8 100644 --- a/Layout/generate.go +++ b/Layout/generate.go @@ -1,4 +1,4 @@ -package Layout +package layout // Generate function generates application layout func Generate(css, html, script string) string { diff --git a/Example/example.go b/examples/example.go similarity index 86% rename from Example/example.go rename to examples/example.go index 2a6b13d..f776025 100644 --- a/Example/example.go +++ b/examples/example.go @@ -1,9 +1,9 @@ -package Example +package examples import ( + "fmt" connect "github.com/vatsimnetwork/connect-go" "github.com/vatsimnetwork/connect-go/handle" - "fmt" "log" "net/http" ) @@ -25,5 +25,5 @@ func callback(w http.ResponseWriter, r *http.Request) { func main() { connect.URL() http.HandleFunc("/connect/callback", callback) - http.ListenAndServe(":3000", nil) + log.Fatal(http.ListenAndServe(":3000", nil)) } \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..f29eda9 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module connect-go + +go 1.15 + +require ( + github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect + github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab + github.com/vatsimnetwork/connect-go v0.0.0-20200609160753-ca8779ee3fc5 + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3a9b708 --- /dev/null +++ b/go.sum @@ -0,0 +1,19 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 h1:sDMmm+q/3+BukdIpxwO365v/Rbspp2Nt5XntgQRXq8Q= +github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= +github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab h1:xveKWz2iaueeTaUgdetzel+U7exyigDYBryyVfV/rZk= +github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/vatsimnetwork/connect-go v0.0.0-20200609160753-ca8779ee3fc5 h1:Rpm7hdyoLbwOsBY832imp/QFlWMQGp4Yzz5y96Ql8Pw= +github.com/vatsimnetwork/connect-go v0.0.0-20200609160753-ca8779ee3fc5/go.mod h1:GYpi0z68ZWnVVF0snFOdHD5D1sJVLz3YKaNrugRH4C8= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/main.go b/main.go index 4c248f8..f8190ac 100644 --- a/main.go +++ b/main.go @@ -8,15 +8,15 @@ import ( // URL function returns connect urls to main application function func URL() { - http.HandleFunc("/connect/login", Handle.Login) - http.HandleFunc("/connect/install", Handle.Env) + http.HandleFunc("/connect/login", handle.Login) + http.HandleFunc("/connect/install", handle.Env) } // MartiniURL function returns url to marting application routes func MartiniURL(m martini.ClassicMartini) { m.Group("/connect", func (r martini.Router) { - r.Get("/connect/login", Handle.Login) - r.Post("/connect/install", Handle.Env) - r.Get("/connect/install", Handle.Env) + r.Get("/connect/login", handle.Login) + r.Post("/connect/install", handle.Env) + r.Get("/connect/install", handle.Env) }) } \ No newline at end of file