[PR #48] [MERGED] Handle serving from a sub-path #131

Closed
opened 2026-02-27 10:15:53 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/matze/wastebin/pull/48
Author: @aldur
Created: 2/12/2024
Status: Merged
Merged: 2/25/2024
Merged by: @matze

Base: masterHead: handle_base_path


📝 Commits (5)

  • 3dfe1ec Iteration #1: Handle serving from a sub-path
  • 63ee34c One more meta.base_path
  • cbb71a1 Add BasePath newtype and cleanup
  • 8208277 Fix string interpolation
  • a025b0f Add tests for base_path

📊 Changes

17 files changed (+138 additions, -54 deletions)

View changed files

📝 .github/workflows/rust.yml (+1 -0)
📝 src/env.rs (+53 -0)
📝 src/highlight.rs (+1 -1)
📝 src/id.rs (+1 -1)
📝 src/main.rs (+13 -8)
📝 src/pages.rs (+12 -0)
📝 src/routes/assets.rs (+2 -1)
📝 src/routes/form.rs (+9 -7)
📝 src/routes/json.rs (+3 -1)
📝 src/routes/mod.rs (+25 -19)
📝 src/routes/paste.rs (+2 -1)
📝 src/test_helpers.rs (+2 -1)
📝 templates/base.html (+3 -3)
📝 templates/burn.html (+1 -1)
📝 templates/error.html (+1 -1)
📝 templates/index.html (+1 -1)
📝 templates/paste.html (+8 -8)

📄 Description

Hi there! 👋

I took a shot at letting wastebin work when served from a sub-path (e.g. https://example.com/wastsebin/). It's a WIP, but I thought of getting this out early and discuss 1. if useful; 2. improvements.

The idea is to re-use the WASTEBIN_BASE_URL variable and get its path component (if any).

Right now:

  • Existing tests pass.
  • It works™.
  • If required, clean-up.
  • Add tests for the sub-path implementation.

What's the best approach to add the test? Duplicate them? Run them in a for loop with / without the sub-path?
Also, I am not convinced of storing the base path in the metadata as a static variable. Are there other approaches?


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/matze/wastebin/pull/48 **Author:** [@aldur](https://github.com/aldur) **Created:** 2/12/2024 **Status:** ✅ Merged **Merged:** 2/25/2024 **Merged by:** [@matze](https://github.com/matze) **Base:** `master` ← **Head:** `handle_base_path` --- ### 📝 Commits (5) - [`3dfe1ec`](https://github.com/matze/wastebin/commit/3dfe1ec958a70556c689dde51f48aaa4576a16fc) Iteration #1: Handle serving from a sub-path - [`63ee34c`](https://github.com/matze/wastebin/commit/63ee34c8b43af941b9b8ffd881d45e7bda0d07e4) One more `meta.base_path` - [`cbb71a1`](https://github.com/matze/wastebin/commit/cbb71a1a28c0a0a21af786e25e8705d131aed86f) Add `BasePath` newtype and cleanup - [`8208277`](https://github.com/matze/wastebin/commit/82082770f3468d37b08604186715e08b0903eae3) Fix string interpolation - [`a025b0f`](https://github.com/matze/wastebin/commit/a025b0f7688d33f6d86fa7bc5f4dc9fb0f118d62) Add tests for base_path ### 📊 Changes **17 files changed** (+138 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/rust.yml` (+1 -0) 📝 `src/env.rs` (+53 -0) 📝 `src/highlight.rs` (+1 -1) 📝 `src/id.rs` (+1 -1) 📝 `src/main.rs` (+13 -8) 📝 `src/pages.rs` (+12 -0) 📝 `src/routes/assets.rs` (+2 -1) 📝 `src/routes/form.rs` (+9 -7) 📝 `src/routes/json.rs` (+3 -1) 📝 `src/routes/mod.rs` (+25 -19) 📝 `src/routes/paste.rs` (+2 -1) 📝 `src/test_helpers.rs` (+2 -1) 📝 `templates/base.html` (+3 -3) 📝 `templates/burn.html` (+1 -1) 📝 `templates/error.html` (+1 -1) 📝 `templates/index.html` (+1 -1) 📝 `templates/paste.html` (+8 -8) </details> ### 📄 Description Hi there! 👋 I took a shot at letting `wastebin` work when served from a sub-path (e.g. https://example.com/wastsebin/). It's a WIP, but I thought of getting this out early and discuss 1. if useful; 2. improvements. The idea is to re-use the `WASTEBIN_BASE_URL` variable and get its `path` component (if any). Right now: - [X] Existing tests pass. - [X] It works™. - [x] If required, clean-up. - [x] Add tests for the sub-path implementation. What's the best approach to add the test? Duplicate them? Run them in a `for` loop with / without the sub-path? Also, I am not convinced of storing the base path in the `metadata` as a static variable. Are there other approaches? --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 10:15:53 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/wastebin-matze#131
No description provided.