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

Raw Byte-Array values for Bodies and FormData #67

Merged
merged 5 commits into from
Sep 9, 2024

Conversation

manego
Copy link
Contributor

@manego manego commented Sep 6, 2024

In this branch, the possibility to pass raw byte arrays to the [Body] and the [FormData] blocks was added.
Documentation is still missing and will be written after first Review

@manego manego requested a review from zekroTJA September 6, 2024 16:08
@manego manego linked an issue Sep 6, 2024 that may be closed by this pull request
@manego manego marked this pull request as ready for review September 6, 2024 16:15
Copy link
Member

@zekroTJA zekroTJA left a comment

Choose a reason for hiding this comment

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

Also, as we already discussed, we should add docs for the new feature.

Everything else looks great so far, thanks for the contribution. 🐐

Comment on lines 820 to 828
func (t *Parser) parseRawDescriptor() (ast.DataContent, error) {
tk, varName := t.s.scanString()
if tk != tokSTRING {
return ast.NoContent{}, ErrInvalidFileDescriptor
}
rd := ast.RawDescriptor{VarName: varName}

return rd, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

I think, it would make sense to also add the content type specification as same as with file descriptors here.

Example:

[FormData]
image = $uploadedImage:image/png

// or

[Body]
$uploadedImage:image/png

This should be relatively easy by using the same implementation from file descriptors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Added contentType to RawDescriptor
  2. Added parameter substitution for [FormData] values
  3. Added documentation

@manego manego requested a review from zekroTJA September 9, 2024 14:31
@zekroTJA zekroTJA changed the base branch from main to dev-v1.3.0 September 9, 2024 14:52
@zekroTJA zekroTJA merged commit bed236b into dev-v1.3.0 Sep 9, 2024
5 checks passed
@manego manego deleted the am/form-data-improvement branch September 9, 2024 16:02
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.

FormData: Pass raw bytes buffer as file input and allow substitution
2 participants