-
Notifications
You must be signed in to change notification settings - Fork 10
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
implements POST /query #612
Conversation
Signed-off-by: Bruno Calza <brunoangelicalza@gmail.com>
8edf8e8
to
48d85ae
Compare
Makefile
Outdated
@@ -80,7 +80,7 @@ lint: | |||
.PHONY: lint | |||
|
|||
# OpenAPI | |||
SPEC_URL=https://raw.githubusercontent.com/tablelandnetwork/docs/main/specs/validator/tableland-openapi-spec.yaml | |||
SPEC_URL=https://raw.githubusercontent.com/tablelandnetwork/docs/bcalza/postquery/specs/validator/tableland-openapi-spec.yaml |
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.
points to the new spec. gotta change this before merge
@@ -265,6 +270,65 @@ func (c *Controller) GetTableQuery(rw http.ResponseWriter, r *http.Request) { | |||
_, _ = rw.Write(formatted) | |||
} | |||
|
|||
// PostTableQuery handles the POST /query call. | |||
func (c *Controller) PostTableQuery(rw http.ResponseWriter, r *http.Request) { |
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.
new handler for POST /query
@@ -61,6 +61,10 @@ func configureAPIV1Routes( | |||
userCtrl.GetTableQuery, | |||
[]mux.MiddlewareFunc{middlewares.WithLogging, rateLim}, | |||
}, | |||
"QueryByStatementPost": { |
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.
adds new route
return fmt.Errorf("get method: %s", err) | ||
} | ||
|
||
for _, method := range methods { |
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.
connects the route with the handler
@@ -256,6 +256,11 @@ func (c *Controller) GetTableQuery(rw http.ResponseWriter, r *http.Request) { | |||
return | |||
} | |||
|
|||
if len(formatted) == 0 { |
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.
here it is @sanderpick
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.
Lgtm!
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.
looks good!
Signed-off-by: Bruno Calza <brunoangelicalza@gmail.com>
Summary
Implements the
POST /query
spec defined at tablelandnetwork/docs#188Working example on
staging
curl -v --json '{"statement": "SELECT * FROM system_txn_receipts LIMIT 1"}' https://staging.tableland.network/api/v1/query
cc @dtbuchholz
Context
We're adding support for
POST /query
so queries can be sent via body request without the need of encoding the URL.Implementation overview
Generates the code based on a new spec and implements the controller in a similar way to
GET /query
.