Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to return status_code? #233

Open
mcauto opened this issue Oct 22, 2018 · 0 comments
Open

how to return status_code? #233

mcauto opened this issue Oct 22, 2018 · 0 comments

Comments

@mcauto
Copy link

mcauto commented Oct 22, 2018

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant