Skip to content

Commit

Permalink
add health endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinfuchs committed Sep 19, 2024
1 parent fb44541 commit 2cd5bab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions embedg-server/api/handlers/send_message/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ func (h *SendMessageHandler) HandleRestoreMessageFromWebhook(c *fiber.Ctx, req w
func downloadMessageAttachments(attachments []*discordgo.MessageAttachment) (files []*wire.MessageAttachmentWire) {
filesC := make(chan *wire.MessageAttachmentWire)

// TODO: can this block forever?

for _, attachment := range attachments {
go func(attachment *discordgo.MessageAttachment) {
if attachment.Size > 8*1024*1024 {
Expand Down
4 changes: 4 additions & 0 deletions embedg-server/api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import (
)

func registerRoutes(app *fiber.App, stores *stores, bot *bot.Bot, managers *managers) {
app.Get("/api/health", func(c *fiber.Ctx) error {
return c.SendStatus(fiber.StatusOK)
})

authHandler := auth.New(stores.pg, bot, managers.session)
app.Get("/api/auth/login", authHandler.HandleAuthRedirect)
app.Get("/api/auth/callback", authHandler.HandleAuthCallback)
Expand Down
4 changes: 3 additions & 1 deletion embedg-server/db/s3/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const imagesBucketName = "images"

func (s *BlobStore) UploadFile(ctx context.Context, image *Image) error {
reader := bytes.NewReader(image.Body)
_, err := s.client.PutObject(ctx, imagesBucketName, image.FileName, reader, int64(len(image.Body)), minio.PutObjectOptions{})
_, err := s.client.PutObject(ctx, imagesBucketName, image.FileName, reader, int64(len(image.Body)), minio.PutObjectOptions{
ContentType: image.ContentType,
})
if err != nil {
return err
}
Expand Down

0 comments on commit 2cd5bab

Please sign in to comment.