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

First shot at read api. #22

Merged
merged 10 commits into from
Oct 4, 2016
Merged

First shot at read api. #22

merged 10 commits into from
Oct 4, 2016

Conversation

aenario
Copy link
Contributor

@aenario aenario commented Oct 3, 2016

So this is the first shot at GetDoc API

It is based on 3 commits by @nono which introduce the instance concept.

Some design decisions :

  • a couchdb packages at cozy-stack/couchdb
  • Introducing the notion of database prefix in instance, which joined with doctype give use the database name
  • using gin.ErrorLogger to output json errors
  • Changed status test for healthy and added couchdb to travis

Left TODO :

  • the database naming should be better analysed, for now it will fail if there is a character outside of _$()+-/a-zA-Z0-9 in host or doctype, or if the host doesnt start with a a-z.
  • Need more code comment, will be working on it in parallel with review

@nono, there is a merge conflict with master. I could fix-it by merging master into this branch, or rebasing this branch on master, but it gets messy with your commits included here.

return &CouchdbError{http.StatusServiceUnavailable,
[]byte("{\"error\":\"No couch to seat on.\"}")}
}
body, err := ioutil.ReadAll(resp.Body)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to close the body:

defer resp.Body.Close()

@nono
Copy link
Member

nono commented Oct 3, 2016

I think you should merge master in this branch to resolve the conflict

url := DocURL(dbprefix, doctype, id)
fmt.Printf("[couchdb request] %v\n", url)
req, err := http.NewRequest("GET", url, nil)
req.Header.Add("Accept", "application/json")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this req.Header.Add should probably be after the if err != nil.

@aenario
Copy link
Contributor Author

aenario commented Oct 3, 2016

OK, I figured out what was wrong with my setup (wrong GOPATH in profile made the linters atom plugins fail silently). So now, gofmt get applied, gometalinter too and travis is happy, which makes me happy.

Both your reviews comment have been fixed in f214b15

@nono nono merged commit 57f8a9a into master Oct 4, 2016
@nono nono deleted the read-api branch October 4, 2016 08:05
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

Successfully merging this pull request may close these issues.

None yet

3 participants