This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func main() { | |
| ... | |
| mux := handler(conf) | |
| ... | |
| } | |
| func handler(conf config.Config) chi.Router { | |
| db, err := gorm.Open(mysql.Open(conf.Database.String), &gorm.Config{ | |
| SkipDefaultTransaction: true, | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type DomainError struct { | |
| prefix string | |
| code int | |
| msg string | |
| } | |
| func NewError(prefix string, code int, msg string) error { | |
| return &DomainError{prefix: prefix, code: code, msg: msg} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "io" | |
| "log" | |
| "mime/multipart" | |
| "net/http" | |
| "os" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "io" | |
| "log" | |
| "net/http" | |
| "net/http/httputil" | |
| "os" | |
| "time" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "io" | |
| "log" | |
| "mime/multipart" | |
| "net/http" | |
| "os" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| snsMessage, _ := ReceiveMessage() | |
| message, _ := ParseMessageJSON(snsMessage) | |
| _, err := sqsClient.DeleteMessage(&sqs.DeleteMessageInput{ | |
| QueueUrl: &queueURL, | |
| ReceiptHandle: snsMessage.ReceiptHandle, | |
| }) | |
| if err != nil { | |
| fmt.Errorf("メッセージを削除できませんでした:" + *snsMessage.ReceiptHandle) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| snsMessage, _ := ReceiveMessage() | |
| var message SnsMessage | |
| json.Unmarshal([]byte(*snsMessage.Body), &message) | |
| fmt.Println(message.Message) // "Test Message" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import "time" | |
| type SnsMessage struct { | |
| Type string | |
| MessageId string | |
| TopicArn string | |
| Subject string | |
| Message string | |
| Timestamp time.Time | |
| SignatureVersion int `json:",string"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sqsClient := sqs.New(awsSession) | |
| result, err := sqsClient.ReceiveMessage(&sqs.ReceiveMessageInput{ | |
| QueueUrl: &queueURL, | |
| AttributeNames: aws.StringSlice([]string{ | |
| sqs.MessageSystemAttributeNameSentTimestamp, | |
| }), | |
| MaxNumberOfMessages: aws.Int64(1), | |
| MessageAttributeNames: aws.StringSlice([]string{ | |
| sqs.QueueAttributeNameAll, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| snsClient := sns.New(awsSession) | |
| subject := "Test Subject" | |
| message := "Test Message" | |
| _, err := snsClient.Publish(&sns.PublishInput{ | |
| Subject: &subject, | |
| Message: &message, | |
| TopicArn: &topicARN, | |
| }) |