livebud / livebud/bud

Request mapping on nested routes hard to line up

Open
#170 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs decision
Dominant language
JavaScript
Stars
5.6k
Forks
175
PR merge metrics
No merged PRs in 30d

Description

Given the following comments controller in **controller/posts/comments/controller.go**:

```go
package comments

type Controller struct {}

type Input struct {
PostID int
}

func (c *Controller) Index(in *Input) *Input {
return in
}
```

And the following request `GET /posts/10/comments`. The resulting request map from this request is:

```
{
"post_id": 10
}
```

Unfortunately, that doesn't line up with `PostID`. Either:

1. The request map would be `{ "PostID": 10 }`
2. Or the PostID field has a `json:"post_id"` struct tag.

This isn't too obvious. I think I'd like the protocol between controller and request map to be strict (e.g. matching, case-sensitive keys) to avoid multiple, valid different request maps, but this might be too cumbersome without proper validation errors (coming soon!).

Contributor guide

No contributing guide indexed for this repository

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

Read controller/posts/comments/controller.go and trace the request mapping for GET /posts/10/comments. Compare the generated post_id key with Input.PostID, then resolve whether strict case-sensitive keys or struct tags are the intended contract. Done means the contract is explicit and the nested-route example maps consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.