Skip to content

Commit

Permalink
Make this an internal endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mjh1 committed Feb 21, 2024
1 parent a9c42a7 commit 273e311
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 0 additions & 6 deletions api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ func NewCatalystAPIRouter(cli config.Cli, vodEngine *pipeline.Coordinator, bal b
for _, path := range [...]string{"/asset/hls/:playbackID/*file", "/webrtc/:playbackID"} {
router.OPTIONS(path, playback)
}
image := middleware.LogAndMetrics(metrics.Metrics.ImageAPIDurationSec)(
withCORS(
handlers.NewImageHandler(cli.PublicBucketURLs).Handle,
),
)
router.GET("/asset/image/:playbackID/thumbnail.jpg", image)

// Handling incoming playback redirection requests
redirectHandler := withLogging(withCORS(geoHandlers.RedirectHandler()))
Expand Down
9 changes: 9 additions & 0 deletions api/http_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/livepeer/catalyst-api/handlers/misttriggers"
"github.com/livepeer/catalyst-api/log"
mistapiconnector "github.com/livepeer/catalyst-api/mapic"
"github.com/livepeer/catalyst-api/metrics"
"github.com/livepeer/catalyst-api/middleware"
"github.com/livepeer/catalyst-api/pipeline"
"github.com/livepeer/go-api-client"
Expand Down Expand Up @@ -113,6 +114,14 @@ func NewCatalystAPIRouterInternal(cli config.Cli, vodEngine *pipeline.Coordinato
),
),
)
router.GET("/api/image/:playbackID/thumbnail.jpg",
middleware.LogAndMetrics(metrics.Metrics.ImageAPIDurationSec)(
withAuth(
cli.APIToken,
handlers.NewImageHandler(cli.PrivateBucketURLs).Handle,
),
),
)

// Public handler to propagate an event to all Catalyst nodes
router.POST("/api/events", withLogging(eventsHandler.Events()))
Expand Down
4 changes: 3 additions & 1 deletion handlers/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ func (p *ImageHandler) handle(w http.ResponseWriter, playbackID string, t float6

// extract image
extractStart := time.Now()
defer metrics.Metrics.ImageAPIExtractDurationSec.WithLabelValues().Observe(time.Since(extractStart).Seconds())
defer func() {
metrics.Metrics.ImageAPIExtractDurationSec.WithLabelValues().Observe(time.Since(extractStart).Seconds())
}()

var ffmpegErr bytes.Buffer
err = ffmpeg.
Expand Down

0 comments on commit 273e311

Please sign in to comment.