Skip to content

Commit

Permalink
handlers: exit if a bad request or error is encountered
Browse files Browse the repository at this point in the history
  • Loading branch information
emranemran committed Nov 10, 2022
1 parent 05265f5 commit b33427b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion handlers/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,21 @@ func (d *CatalystAPIHandlersCollection) UploadVOD() httprouter.Handle {
// Use the output directory specified in request as the output directory of transcoded renditions
targetURL, err := url.Parse(tURL)
if err != nil {
errors.WriteHTTPBadRequest(w, "Invalid request payload", fmt.Errorf("target output file shoul d end in .m3u8 extension"))
errors.WriteHTTPBadRequest(w, "Invalid request payload", fmt.Errorf("target output file should end in .m3u8 extension"))
return
}
targetDirPath := path.Dir(targetURL.Path)
targetManifestFilename := path.Base(targetURL.String())
targetExtension := path.Ext(targetManifestFilename)
if targetExtension != ".m3u8" {
errors.WriteHTTPBadRequest(w, "Invalid request payload", fmt.Errorf("target output file should end in .m3u8 extension"))
return
}
targetSegmentedOutputPath := path.Join(targetDirPath, "source", targetManifestFilename)
sout, err := url.Parse(targetSegmentedOutputPath)
if err != nil {
errors.WriteHTTPInternalServerError(w, "Cannot parse targetSegmentedOutputPath", err)
return
}

targetSegmentedOutputURL := targetURL.ResolveReference(sout)
Expand All @@ -137,6 +140,7 @@ func (d *CatalystAPIHandlersCollection) UploadVOD() httprouter.Handle {
// process the request
if err := d.processUploadVOD(streamName, uploadVODRequest.Url, targetSegmentedOutputURL.String()); err != nil {
errors.WriteHTTPInternalServerError(w, "Cannot process upload VOD request", err)
return
}

if err := clients.DefaultCallbackClient.SendTranscodeStatus(uploadVODRequest.CallbackUrl, clients.TranscodeStatusPreparing, 0.0); err != nil {
Expand Down

0 comments on commit b33427b

Please sign in to comment.