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

add API for crates.io to trigger rebuilds #2534

Merged
merged 8 commits into from
Jul 11, 2024
Merged

Commits on Jul 11, 2024

  1. preparations for API to request rebuild of a crate version

    - web: `axum_cached_redirect`: change return type to be concrete
    - web/routes: add `post_internal`
    - test: add `TestFrontent::post`
    pflanze committed Jul 11, 2024
    Configuration menu
    Copy the full SHA
    bb0212b View commit details
    Browse the repository at this point in the history
  2. web/error: add JsonAxumNope for JSON APIs

    This aims to satisfy these wishes:
    
    - Use the same error enum (`AxumNope`) for both handlers returning
      HTML or JSON.
    
    - Yet allow those handlers to specify whether HTML or JSON should be
      returned.
    
    - Not change the exising code returning `AxumNope`--still convert to
      HTML by default.
    
    Because `AxumNope` also contains a case (`Search`) that is fixed to
    producing HTML, but shouldn't ever be used by handlers returning JSON,
    that works with a runtime error in case the latter assumption isn't
    being followed.
    
    The approach is to add a new wrapper around `AxumNope` called
    `JsonAxumNope` and matching type def `JsonAxumResult`. The wrapper
    also implements `IntoResponse`, but produces JSON. Endpoints wishing
    to return JSON errors need to use that wrapper and specify
    `JsonAxumResult` as their return type.
    pflanze committed Jul 11, 2024
    Configuration menu
    Copy the full SHA
    aaf7ea5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    cf58d70 View commit details
    Browse the repository at this point in the history
  4. web/builds: add API to request rebuild of a crate version

    This resolves rust-lang#2442.
    
    - adds config variable `DOCSRS_TRIGGER_REBUILD_TOKEN` /
      `Config.trigger_rebuild_token`
    
    - adds `build_trigger_rebuild_handler` and route
      "/crate/:name/:version/rebuild"
    
    Note: does not yet contain any kind of rate limiting!
    pflanze committed Jul 11, 2024
    Configuration menu
    Copy the full SHA
    464a4c0 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    005a072 View commit details
    Browse the repository at this point in the history
  6. web/error: simplify JsonAxumNope implementation

    This removes the intermediate `ErrorResponse` type and instead pattern
    matches AxumNope on both levels, using a new function
    `redirect_with_policy` to avoid duplication.
    
    (Saves 11 lines of code, 7 comment lines, and the indirection via
    intermediate type, but adds the function instead.)
    pflanze committed Jul 11, 2024
    Configuration menu
    Copy the full SHA
    d5e6da8 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    247d86b View commit details
    Browse the repository at this point in the history
  8. Run "cargo sqlx prepare"

    pflanze committed Jul 11, 2024
    Configuration menu
    Copy the full SHA
    108356a View commit details
    Browse the repository at this point in the history