Skip to content
This repository has been archived by the owner on Jan 30, 2025. It is now read-only.

Commit

Permalink
Correct package names
Browse files Browse the repository at this point in the history
  • Loading branch information
MatanBudimir committed Aug 27, 2020
1 parent ca8779e commit 26394d6
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Handle/callback.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Handle
package handle

// Connect callback after successful client authentication

Expand Down
10 changes: 5 additions & 5 deletions Handle/env.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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("", "<form method=\"POST\" action=\"\">" +
error := layout.Generate("", "<form method=\"POST\" action=\"\">" +
"<center><h1 style=\"color: red;\">Forbidden</h1></center>" +
"</form>", "")

Expand Down
10 changes: 5 additions & 5 deletions Handle/login.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package Handle
package handle

import (
"connect-go/Helpers"
"connect-go/helpers"
"fmt"
"net/http"
"os"
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion Handle/structs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Handle
package handle

// An Access represents access token which we get from AccessToken function
type Access struct {
Expand Down
2 changes: 1 addition & 1 deletion Helpers/check.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Helpers
package helpers

import (
"os"
Expand Down
2 changes: 1 addition & 1 deletion Helpers/string.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Helpers
package helpers

import (
"math/rand"
Expand Down
2 changes: 1 addition & 1 deletion Layout/generate.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package Layout
package layout

// Generate function generates application layout
func Generate(css, html, script string) string {
Expand Down
6 changes: 3 additions & 3 deletions Example/example.go → examples/example.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand All @@ -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))
}
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
)
19 changes: 19 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

0 comments on commit 26394d6

Please sign in to comment.