Make error a predefined variable for later comparision

Open
#24 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
go
Domain
api

Research direction

Start at decoder.go line 30, linked in the issue, and inspect how the decoding error is returned. Define a predefined error for the missing content type case so callers can compare the returned error and choose a custom response; done means that specific error is identifiable to application developers.

Written by the indexing model from the issue text.

Description

https://github.com/go-chi/render/blob/3215478343fbc559bd3fc08f7031bb134d6bdad5/decoder.go#L30

If the returned error are defined var, it would be possible to compare and know what exactly happened. The error message from render package cannot be directly to client in most cases, but application developer would like to return some custom error.

var (
    ErrContentTypeNotSet = errors.New("render: missing content-type, unable to automatically decode the request content") 
)

would be helpful.

Dominant language
Go
Stars
341
Forks
68
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from go-chi/render

All issues in go-chi/render

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.