go-json-rest
go-json-rest copied to clipboard
how to return status_code?
I build this project example.
in Countries demo
curl -i -H 'Content-Type: application/json' \
-d '{"Code":"FR","Name":"France"}' http://127.0.0.1:8080/countries
# it has to return 201(CREATED), but return 200(OK)
curl -i -H 'Content-Type: application/json' \
-d '{"Code":"US","Name":"United States"}' http://127.0.0.1:8080/countries
# it has to return 201(CREATED), but return 200(OK)
curl -i -H 'Content-Type: application/json' \
-d '{"Code":"US","Name":"United States"}' http://127.0.0.1:8080/countries
# return 209(CONFLICT) I customed
curl -i http://127.0.0.1:8080/countries/FR
curl -i http://127.0.0.1:8080/countries/US
curl -i http://127.0.0.1:8080/countries
curl -i -X DELETE http://127.0.0.1:8080/countries/FR
curl -i http://127.0.0.1:8080/countries
curl -i -X DELETE http://127.0.0.1:8080/countries/US
curl -i http://127.0.0.1:8080/countries
if data is conflict
if store[country.Code] != nil {
rest.Error(w, "conflict", 409)
return
}
but I don't know modified response_code override. could you help me?