luckyframework / luckyframework/lucky_cli

Add `set_default_content_type` to `ApiAction`

Open
#285 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
92
Forks
48
PR merge metrics
No merged PRs in 30d

Description

If a client forgets to set a content type, we should set a default for them so that Lucky knows what kind of params to expect.

I think we can add a `before set_default_content_type` to `ApiAction` and the method would look something like this:

```crystal
def set_default_content_type
response.headers["Content-Type"] ||= "application/json"
continue
end
```

@jwoertink could you try this in your app and leave feedback on if it works/suggested improvements?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating ApiAction and reading how its before hooks and response headers are handled. Verify that a missing content type receives the proposed JSON default and that existing content types remain unchanged; the issue does not name a test file.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
api, backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.