Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define new API endpoint + test #17

Merged
merged 4 commits into from Aug 15, 2022
Merged

Define new API endpoint + test #17

merged 4 commits into from Aug 15, 2022

Conversation

AlexKordic
Copy link
Contributor

  • New handler /api/transcode/file added to func StartCatalystAPIRouter()
  • Use gojsonschema to check input json.
  • Just return OK for now and invoke callback.
  • Testing request json format and required fields.
  • Testing is callback invoked by handler.

@AlexKordic
Copy link
Contributor Author

@thomshutt Wondering about repeated requests. How would entire system detect duplicate transcode jobs? Duplicate transcode request can have different callback URL, then we should also call this URL on completion.


schema, err := gojsonschema.NewSchema(schemaLoader)
if err != nil {
panic(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's handle it a bit more gracefully

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could move the error on program start and panic early.. let me see how

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed please check this commit

handlers/handlers.go Outdated Show resolved Hide resolved
handlers/webhook.go Outdated Show resolved Hide resolved

func WriteHTTPBadBodySchema(where string, w http.ResponseWriter, errors []gojsonschema.ResultError) apiError {
sb := strings.Builder{}
sb.WriteString("Body validation error in ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see people use the String Builder very often in Go, normally stuff like this is done with a fmt.Sprintf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted.

@AlexKordic AlexKordic merged commit b7d3cff into main Aug 15, 2022
@thomshutt thomshutt deleted the ak/transcode_endpoint branch August 15, 2022 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants