Skip to content

Commit

Permalink
Merge pull request #185 from p4tin/improve_queue_urls
Browse files Browse the repository at this point in the history
Improve Queue URL paths
  • Loading branch information
p4tin authored Dec 29, 2018
2 parents ceeb88b + 13c39fb commit c0c3d20
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.idea

vendor/
deployments/

goaws
goaws_linux_amd64
Expand Down
4 changes: 2 additions & 2 deletions app/conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func LoadYamlConfig(filename string, env string) []string {
app.SyncQueues.Lock()
app.SyncTopics.Lock()
for _, queue := range envs[env].Queues {
queueUrl := "http://" + app.CurrentEnvironment.Region + "." + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/" + app.CurrentEnvironment.AccountID + "/" + queue.Name
queueUrl := "http://sqs." + app.CurrentEnvironment.Region + "." + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/" + app.CurrentEnvironment.AccountID + "/" + queue.Name
queueArn := "arn:aws:sqs:" + app.CurrentEnvironment.Region + ":" + app.CurrentEnvironment.AccountID + ":" + queue.Name

if queue.ReceiveMessageWaitTimeSeconds == 0 {
Expand All @@ -92,7 +92,7 @@ func LoadYamlConfig(filename string, env string) []string {
for _, subs := range topic.Subscriptions {
if _, ok := app.SyncQueues.Queues[subs.QueueName]; !ok {
//Queue does not exist yet, create it.
queueUrl := "http://" + app.CurrentEnvironment.Region + "." + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/" + app.CurrentEnvironment.AccountID + "/" + subs.QueueName
queueUrl := "http://sqs." + app.CurrentEnvironment.Region + "." + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/" + app.CurrentEnvironment.AccountID + "/" + subs.QueueName
queueArn := "arn:aws:sqs:" + app.CurrentEnvironment.Region + ":" + app.CurrentEnvironment.AccountID + ":" + subs.QueueName
app.SyncQueues.Queues[subs.QueueName] = &app.Queue{
Name: subs.QueueName,
Expand Down
12 changes: 6 additions & 6 deletions app/gosns/gosns.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ func Subscribe(w http.ResponseWriter, req *http.Request) {
Token: token,
TopicArn: topicArn,
Message: "You have chosen to subscribe to the topic " + topicArn + ".\nTo confirm the subscription, visit the SubscribeURL included in this message.",
SigningCertURL: "http://" + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/SimpleNotificationService/" + uuid + ".pem",
SigningCertURL: "http://sqs." + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/SimpleNotificationService/" + uuid + ".pem",
SignatureVersion: "1",
SubscribeURL: "http://" + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/?Action=ConfirmSubscription&TopicArn=" + topicArn + "&Token=" + token,
SubscribeURL: "http://sqs." + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/?Action=ConfirmSubscription&TopicArn=" + topicArn + "&Token=" + token,
Timestamp: time.Now().UTC().Format(time.RFC3339),
}
signature, err := signMessage(PrivateKEY, snsMSG)
Expand Down Expand Up @@ -552,8 +552,8 @@ func publishHTTP(subs *app.Subscription, messageBody string, messageAttributes m
Message: messageBody,
Timestamp: time.Now().UTC().Format(time.RFC3339),
SignatureVersion: "1",
SigningCertURL: "http://" + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/SimpleNotificationService/" + id + ".pem",
UnsubscribeURL: "http://" + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/?Action=Unsubscribe&SubscriptionArn=" + subs.SubscriptionArn,
SigningCertURL: "http://sqs." + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/SimpleNotificationService/" + id + ".pem",
UnsubscribeURL: "http://sqs." + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/?Action=Unsubscribe&SubscriptionArn=" + subs.SubscriptionArn,
MessageAttributes: formatAttributes(messageAttributes),
}

Expand Down Expand Up @@ -679,8 +679,8 @@ func CreateMessageBody(subs *app.Subscription, msg string, subject string, messa
Subject: subject,
Timestamp: time.Now().UTC().Format(time.RFC3339),
SignatureVersion: "1",
SigningCertURL: "http://" + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/SimpleNotificationService/" + msgId + ".pem",
UnsubscribeURL: "http://" + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/?Action=Unsubscribe&SubscriptionArn=" + subs.SubscriptionArn,
SigningCertURL: "http://sqs." + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/SimpleNotificationService/" + msgId + ".pem",
UnsubscribeURL: "http://sqs." + app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port + "/?Action=Unsubscribe&SubscriptionArn=" + subs.SubscriptionArn,
MessageAttributes: formatAttributes(messageAttributes),
}

Expand Down
2 changes: 1 addition & 1 deletion app/gosqs/gosqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func CreateQueue(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/xml")
queueName := req.FormValue("QueueName")
host := app.CurrentEnvironment.Host + ":" + app.CurrentEnvironment.Port
queueUrl := "http://" + app.CurrentEnvironment.Region + "." + host + "/" + app.CurrentEnvironment.AccountID + "/" + queueName
queueUrl := "http://sqs." + app.CurrentEnvironment.Region + "." + host + "/" + app.CurrentEnvironment.AccountID + "/" + queueName
queueArn := "arn:aws:sqs:" + app.CurrentEnvironment.Region + ":" + app.CurrentEnvironment.AccountID + ":" + queueName

if _, ok := app.SyncQueues.Queues[queueName]; !ok {
Expand Down
4 changes: 2 additions & 2 deletions app/gosqs/gosqs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func TestCreateQueuehandler_POST_CreateQueue(t *testing.T) {
}
expectedQueue := &app.Queue{
Name: queueName,
URL: "http://.://" + queueName,
URL: "http://sqs..://" + queueName,
Arn: "arn:aws:sqs:::" + queueName,
TimeoutSecs: 60,
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func TestCreateFIFOQueuehandler_POST_CreateQueue(t *testing.T) {
}
expectedQueue := &app.Queue{
Name: queueName,
URL: "http://.://" + queueName,
URL: "http://sqs..://" + queueName,
Arn: "arn:aws:sqs:::" + queueName,
TimeoutSecs: 60,
IsFIFO: true,
Expand Down

0 comments on commit c0c3d20

Please sign in to comment.