[Solved] http: panic serving 127.0.0.1:48286: EOF [closed]


As mentioned in the comments by Volker you are currently panic’ing when you don’t receive json according to your spec – it’s safe to assume this should not be the case, so do some proper error handling.


Nonetheless you’re code is currently working, assuming you have something similar to this struct:

type ip struct {
    Ip string `json:"ip"`
}

You can post content matching this struct:

curl -d '{"ip":"128.0.0.1"}' -H "Content-Type: application/json" -X POST http://localhost:8000/

This will return:

{"status":1}

solved http: panic serving 127.0.0.1:48286: EOF [closed]