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

Update web hosting api to handle splited transaction #374

Conversation

Neylix
Copy link
Member

@Neylix Neylix commented Jun 13, 2022

Description

This PR updates web_hosting API to handle files with their content in another transaction(s).

Fixes #340

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Tested with Archethic Website sent by aeweb cli.
Also add tests in test files

To test, refer to archethic-foundation/aeweb-cli#64

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Neylix Neylix added feature New feature request API Involve API facing user labels Jun 13, 2022
@Neylix Neylix requested review from a user and internet-zero June 13, 2022 10:47
defp encode_res(conn, file_content, encodage) do
accept_encoding = get_req_header(conn, "accept-encoding")

case !Enum.empty?(accept_encoding) and
Copy link

Choose a reason for hiding this comment

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

I think you can simplify using simple case:

case get_req_header(conn, "accept_encoding") do
   [] ->
       # Do something when it's empty
    accept_encoding ->
       # Do something when it's not empty
end

Copy link
Member Author

@Neylix Neylix Jun 15, 2022

Choose a reason for hiding this comment

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

Yes but there will be code duplication because we have the same action to do when accept_encoding is empty and when it is not empty but don't contain "gzip"

Copy link

Choose a reason for hiding this comment

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

You can use with statement to chain conditions

@ghost ghost merged commit 714799c into archethic-foundation:develop Jun 15, 2022
@Neylix Neylix deleted the Update-web-hosting-API-to-handle-splited-transaction branch June 15, 2022 13:31
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Involve API facing user feature New feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant