Skip to content

Conversation

patrickdappollonio
Copy link
Owner

No description provided.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR performs a broad cleanup and refactoring of the HTTP server internals, extracting repeated logic into helpers and unifying error handling.

  • Introduces httputil.Error, makeAbsPath, handleError, and other helper methods to centralize common operations.
  • Refactors directory listing and markdown rendering into smaller units (prepareTemplateData, readDirEntries, handleCustomOutputFormat).
  • Standardizes content-type detection, ETag generation, and JWT validation logic.

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/server/validation.go Renamed FieldToValidationError to fieldToValidationError and updated calls accordingly.
internal/server/handlers.go Extracted path resolution, error handling, content disposition, and templating into helper methods.
internal/server/error_handling.go Switched ValidationError.Value from interface{} to any and renamed converter to unexported form.
internal/pathutil/url.go Added GetParentURL to compute parent directory URLs.
internal/httputil/errors.go Added httputil.Error helper for writing HTTP errors.
internal/fileutil/files.go Added FileExists, IsMarkdownFile, IsIndexFile, and IsHTMLIndexFile utilities.
internal/mdrendering/goldmark_renderer.go Improved image alt-text rendering by walking AST child nodes.
internal/middlewares/jwt_validate.go Refactored JWT parsing with jwt.NewParser, parser options, and more granular error messages.
internal/middlewares/etag.go Switched from sha1 to fnv hashing for ETag and skipped ETag for HEAD requests.
internal/middlewares/disable_config_access.go Added doc comments for DisableAccessToFile middleware.
Comments suppressed due to low confidence (3)

internal/server/handlers.go:364

  • [nitpick] Several new helper methods (prepareTemplateData, readDirEntries, etc.) have been introduced without corresponding unit tests; consider adding tests to ensure template data and directory-reading logic are validated.
func (s *Server) prepareTemplateData(requestedPath string, r *http.Request, files []os.FileInfo, markdownContent *bytes.Buffer, isSingleMarkdown bool) map[string]any {

internal/server/handlers.go:107

  • The identifier allowedIndexFiles is undefined in this scope; it should be indexFiles to reference the correct variable.
if s.FullMarkdownRender || fileutil.IsIndexFile(filepath.Base(currentPath), allowedIndexFiles) {

internal/middlewares/jwt_validate.go:48

  • The time package is not imported, causing a compile error; add import "time" to the imports.
jwt.WithLeeway(time.Second*5), // Small leeway for clock skew

Copy link

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Jun 20, 2025
@github-actions github-actions bot closed this Jun 25, 2025
@patrickdappollonio patrickdappollonio added no stale Mark with this label those issues and pull requests that shouldn't be closed and removed Stale labels Jun 25, 2025
Copy link

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Jul 26, 2025
@github-actions github-actions bot closed this Jul 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no stale Mark with this label those issues and pull requests that shouldn't be closed Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant