Skip to content

Implemented Res.Type() Initial Logic to Specify Content-Type HTTP Response Header.#70

Merged
muhammadzkralla merged 3 commits into
masterfrom
develop
Jun 7, 2025
Merged

Implemented Res.Type() Initial Logic to Specify Content-Type HTTP Response Header.#70
muhammadzkralla merged 3 commits into
masterfrom
develop

Conversation

@muhammadzkralla

Copy link
Copy Markdown
Owner

No description provided.

@muhammadzkralla
muhammadzkralla requested a review from Copilot June 7, 2025 23:06
@muhammadzkralla muhammadzkralla self-assigned this Jun 7, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Introduces the Type method on Res to derive and store a MIME type from various inputs, and adds corresponding table-driven tests.

  • Adds Res.Type(string) *Res to normalize extensions or full MIME types into res.ContentType.
  • Introduces TestContentType to validate common mappings (json, html, text, xml, csv, image formats).

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
response.go Implements Res.Type method with extension lookup and fallback logic.
response_test.go Adds TestContentType to verify Type normalization across inputs.
Comments suppressed due to low confidence (2)

response.go:265

  • The comment says the header is set, but the method only updates res.ContentType. Either update the doc to reflect the actual behavior or have the method also write to res.Headers["Content-Type"].
// Sets the `Content-Type` HTTP response header to the MIME type specified

response_test.go:323

  • Tests verify res.ContentType but don't assert that the Headers map is updated. Add an assertion on res.Headers["Content-Type"] to cover header-writing behavior.
if res.ContentType != tt.expected {

Comment thread response.go
@muhammadzkralla
muhammadzkralla merged commit d6273d7 into master Jun 7, 2025
1 check passed
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.

2 participants