Skip to content

Commit

Permalink
fix/1010 first day path (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
MindHunter86 authored Aug 11, 2024
2 parents f5a99f9 + 6278b0d commit d8cd325
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions internal/proxy/handlers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package proxy

import (
"bytes"
"fmt"

"github.com/gofiber/fiber/v2"
Expand Down Expand Up @@ -46,17 +47,13 @@ func (m *Proxy) HandleRandomRelease(c *fiber.Ctx) (e error) {
"an error occured in randomizer, maybe it's not ready yet")
}

switch c.Method() {
case fiber.MethodGet:
c.Response().Header.Set(fiber.HeaderLocation, "/release/"+release+".html")
return respondPlainWithStatus(c, fiber.StatusFound)
case fiber.MethodPost:
if bytes.Equal(c.Request().PostArgs().Peek("js"), []byte("1")) {
fmt.Fprintln(c, release)
return respondPlainWithStatus(c, fiber.StatusOK)
default:
return fiber.NewError(fiber.StatusServiceUnavailable,
"invalid method has been sent")
}

c.Response().Header.Set(fiber.HeaderLocation, "/release/"+release+".html")
return respondPlainWithStatus(c, fiber.StatusFound)
}

// internal api handlers
Expand Down

0 comments on commit d8cd325

Please sign in to comment.