kataras / kataras/iris

EOF occurs sending a POST with curl

Open
#2,164 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
25.6k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Describe the issue you are facing or ask for help
I used example code like this:
```func create(ctx iris.Context) {
var b Book
err := ctx.ReadJSON(&b)
// TIP: use ctx.ReadBody(&b) to bind
// any type of incoming data instead.
if err != nil {
ctx.StopWithProblem(iris.StatusBadRequest, iris.NewProblem().
Title("Book creation failure").DetailErr(err))
// TIP: use ctx.StopWithError(code, err) when only
// plain text responses are expected on errors.
return
}

println("Received Book: " + b.Title)

ctx.StatusCode(iris.StatusCreated)
}
```
and I ran the server and sent a POST by curl like
![image](https://github.com/kataras/iris/assets/20328337/3b92f125-b711-4230-b52f-79bd76a16c73)
then a response with detail EOF returned
![image](https://github.com/kataras/iris/assets/20328337/126d0e07-bd00-41e6-9c00-0c78b33ef6d5)
My every step is the same as in the example docs,i don't understand why

Contributor guide

Open the contributing guide

Research direction

Start with the shown create handler and the curl request in the linked screenshot, then reproduce the POST against the example documentation. Check that the request contains the expected JSON body and reaches ctx.ReadJSON; done means the handler returns 201 and prints the received book title instead of returning EOF.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.