-
Notifications
You must be signed in to change notification settings - Fork 66
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
refactor(api): aligning our API with spec #1734
Conversation
} | ||
|
||
dsh := NewDatasetHandlers(s.Instance, cfg.API.ReadOnly) | ||
// aggregate endpoints | ||
m.Handle(lib.AEList.String(), s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "dataset.list"))).Methods(http.MethodPost, http.MethodGet) | ||
m.Handle(lib.AEListRaw.String(), s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "dataset.listrawrefs"))).Methods(http.MethodPost, http.MethodGet) | ||
m.Handle(lib.AEPeerList.String(), s.Middleware(dsh.PeerListHandler(lib.AEPeerList.String()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also merge into AEList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this "/peer/list"? It's still there in #1697.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this particular endpoint is not the list of peers, but instead the list of datasets you have from a specific peer. Which I believe would become /list
w/ the filter=ramfox
in the params
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes what @ramfox said.
/peer/list
lists your peers/list/{peer}
lists datasets of a given peer and should be moved into list with the new filtering approach
api/api.go
Outdated
|
||
// dataset endpoints | ||
routeParams = newrefRouteParams(lib.AEWhatChanged, false, false, http.MethodGet, http.MethodPost) | ||
handleRefRoute(m, routeParams, s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "fsi.whatchanged"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the handleRefRoute
mean that these routes include all the sugar which we should drop and lock to POST
only. Only /ds/get
should be an exception for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, yes.
api/api.go
Outdated
handleRefRoute(m, routeParams, s.Middleware(dsh.SaveHandler(lib.AESave.String()))) | ||
routeParams = newrefRouteParams(lib.AEPull, false, false, http.MethodPost, http.MethodPut) | ||
handleRefRoute(m, routeParams, s.Middleware(dsh.PullHandler(lib.AEPull.NoTrailingSlash()))) | ||
routeParams = newrefRouteParams(lib.AEPush, false, false, http.MethodGet, http.MethodPost, http.MethodDelete) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Push should also move into dataset
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe that is correct.
|
||
// dataset endpoints | ||
routeParams = newrefRouteParams(lib.AEWhatChanged, false, false, http.MethodGet, http.MethodPost) | ||
handleRefRoute(m, routeParams, s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "fsi.whatchanged"))) | ||
routeParams = newrefRouteParams(lib.AEGet, false, true, http.MethodGet, http.MethodPost) | ||
handleRefRoute(m, routeParams, s.Middleware(dsh.GetHandler(lib.AEGet.String()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ds/log
is still TODO
m.Handle(lib.AEHistory.String(), s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "log.history"))).Methods(http.MethodPost) | ||
// TODO(aqru): clear up these endpoints up to spec | ||
|
||
m.Handle(lib.AELog.String(), s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "log.history"))).Methods(http.MethodPost) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've had a discussion around these, but I don't have all the details to spell them all out on how we will merge these/how they should behave/which we will just drop from the HTTP API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to #1730, rawlogbook
and logbookssummary
should be dropped from the API, because they're "hard-mode" only. Not totally sure about the other 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe history
will be the /log
endpoint with filter=history
(or selector=history
, whatever language we choose)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments so far
} | ||
|
||
dsh := NewDatasetHandlers(s.Instance, cfg.API.ReadOnly) | ||
// aggregate endpoints | ||
m.Handle(lib.AEList.String(), s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "dataset.list"))).Methods(http.MethodPost, http.MethodGet) | ||
m.Handle(lib.AEListRaw.String(), s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "dataset.listrawrefs"))).Methods(http.MethodPost, http.MethodGet) | ||
m.Handle(lib.AEPeerList.String(), s.Middleware(dsh.PeerListHandler(lib.AEPeerList.String()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this "/peer/list"? It's still there in #1697.
api/api.go
Outdated
|
||
// dataset endpoints | ||
routeParams = newrefRouteParams(lib.AEWhatChanged, false, false, http.MethodGet, http.MethodPost) | ||
handleRefRoute(m, routeParams, s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "fsi.whatchanged"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct, yes.
m.Handle(lib.AEHistory.String(), s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "log.history"))).Methods(http.MethodPost) | ||
// TODO(aqru): clear up these endpoints up to spec | ||
|
||
m.Handle(lib.AELog.String(), s.Middleware(lib.NewHTTPRequestHandler(s.Instance, "log.history"))).Methods(http.MethodPost) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to #1730, rawlogbook
and logbookssummary
should be dropped from the API, because they're "hard-mode" only. Not totally sure about the other 2.
lib/datasets.go
Outdated
// "render": {AE??, "POST"}, | ||
"remove": {AERemove, "POST"}, | ||
"validate": {AEValidate, "POST"}, | ||
// "unpack": {AE??, "POST"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AEUnpack
lib/log.go
Outdated
"history": {AELog, "POST"}, | ||
"entries": {AEEntries, "POST"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear here, I just made this name change from /logbook
to /entries
for clarify, but always intended it to be temporary until we adjust to the new spec. When we do our final refactor, /entries
should be /log
and /history
should be removed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, and yeah I'll be keeping rebasing this as I'm trailing all the other changes.
9f2e5bb
to
9622a06
Compare
Majority of the refactor is done and I would like to land this before making this PR not just a refactor but a big change in the logic of some remaining methods. A list of remaining things: |
Quick observations from the current standing of the PR:
|
hmmm re
I think the easiest thing to do rn would be to remove the remote behavior from the |
This is so lovely. Noticed that you refactored away from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Arqu this is looking great. To avoid further rebasing I vote we merge this now & do follow-ups for any subsequent fixes
Aiming to get us closer to the API spec contained in #1731, I've refactored some of the code to move to POST only, cleaned up the route definitions and rearranged most of the routes in the same order as in our tables. The main reason for rearranging is to make the follow up steps more explicit:
I'll run a round of self commenting on the PR just to add some color to it. Looking for some input before diving into the code move.