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

fix: make the api path naming plural #1013

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions disperser/dataapi/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/batch/{batch_header_hash}": {
"/batches/{batch_header_hash}": {
"get": {
"produces": [
"application/json"
Expand Down Expand Up @@ -61,7 +61,7 @@ const docTemplate = `{
}
}
},
"/blob/{blob_key}": {
"/blobs/{blob_key}": {
"get": {
"produces": [
"application/json"
Expand Down
4 changes: 2 additions & 2 deletions disperser/dataapi/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"version": "1"
},
"paths": {
"/batch/{batch_header_hash}": {
"/batches/{batch_header_hash}": {
"get": {
"produces": [
"application/json"
Expand Down Expand Up @@ -57,7 +57,7 @@
}
}
},
"/blob/{blob_key}": {
"/blobs/{blob_key}": {
"get": {
"produces": [
"application/json"
Expand Down
4 changes: 2 additions & 2 deletions disperser/dataapi/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ info:
title: EigenDA Data Access API
version: "1"
paths:
/batch/{batch_header_hash}:
/batches/{batch_header_hash}:
get:
parameters:
- description: Batch header hash in hex string
Expand Down Expand Up @@ -391,7 +391,7 @@ paths:
summary: Fetch batch by the batch header hash
tags:
- Feed
/blob/{blob_key}:
/blobs/{blob_key}:
get:
parameters:
- description: Blob key in hex string
Expand Down
12 changes: 6 additions & 6 deletions disperser/dataapi/server_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ func (s *ServerV2) Start() error {
{
blob := v2.Group("/blob")
{
blob.GET("/blob/feed", s.FetchBlobFeedHandler)
blob.GET("/blob/:blob_key", s.FetchBlobHandler)
blob.GET("/blobs/feed", s.FetchBlobFeedHandler)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Same comment: FetchBlob -> FetchBlobs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FetchBlob is fetching exactly one blob. The edge case is "FetchBlobsFeed" or "FetchBlobFeed", which I am not sure which one, maybe "blob" is adjective here so "BlobFeed" sounds right?

blob.GET("/blobs/:blob_key", s.FetchBlobHandler)
}
batch := v2.Group("/batch")
{
batch.GET("/batch/feed", s.FetchBatchFeedHandler)
batch.GET("/batch/:batch_header_hash", s.FetchBatchHandler)
batch.GET("/batches/feed", s.FetchBatchFeedHandler)
batch.GET("/batches/:batch_header_hash", s.FetchBatchHandler)
}
operators := v2.Group("/operators")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or we make it /operator/... if it's preferred

Copy link
Contributor

Choose a reason for hiding this comment

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

Think plural is better since the response is for multiple operators right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be for a single operator as well. I think it's like "this is API for dealing with multi operators" rather than saying it'll just be returning one or multiple

{
Expand Down Expand Up @@ -180,7 +180,7 @@ func (s *ServerV2) FetchBlobFeedHandler(c *gin.Context) {
// @Failure 400 {object} ErrorResponse "error: Bad request"
// @Failure 404 {object} ErrorResponse "error: Not found"
// @Failure 500 {object} ErrorResponse "error: Server error"
// @Router /blob/{blob_key} [get]
// @Router /blobs/{blob_key} [get]
func (s *ServerV2) FetchBlobHandler(c *gin.Context) {
start := time.Now()
blobKey, err := corev2.HexToBlobKey(c.Param("blob_key"))
Expand Down Expand Up @@ -221,7 +221,7 @@ func (s *ServerV2) FetchBatchFeedHandler(c *gin.Context) {
// @Failure 400 {object} ErrorResponse "error: Bad request"
// @Failure 404 {object} ErrorResponse "error: Not found"
// @Failure 500 {object} ErrorResponse "error: Server error"
// @Router /batch/{batch_header_hash} [get]
// @Router /batches/{batch_header_hash} [get]
func (s *ServerV2) FetchBatchHandler(c *gin.Context) {
start := time.Now()
batchHeaderHashHex := c.Param("batch_header_hash")
Expand Down
8 changes: 4 additions & 4 deletions disperser/dataapi/server_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ func TestFetchBlobHandlerV2(t *testing.T) {
require.NoError(t, err)
require.NoError(t, err)

r.GET("/v2/blob/:blob_key", testDataApiServerV2.FetchBlobHandler)
r.GET("/v2/blobs/:blob_key", testDataApiServerV2.FetchBlobHandler)
w := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/v2/blob/"+blobKey.Hex(), nil)
req := httptest.NewRequest(http.MethodGet, "/v2/blobs/"+blobKey.Hex(), nil)
r.ServeHTTP(w, req)
res := w.Result()
defer res.Body.Close()
Expand Down Expand Up @@ -232,9 +232,9 @@ func TestFetchBatchHandlerV2(t *testing.T) {
err = blobMetadataStore.PutAttestation(context.Background(), attestation)
require.NoError(t, err)

r.GET("/v2/batch/:batch_header_hash", testDataApiServerV2.FetchBatchHandler)
r.GET("/v2/batches/:batch_header_hash", testDataApiServerV2.FetchBatchHandler)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Rename functions to match? FetchBatchHandler -> FetchBatchesHandler?

w := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/v2/batch/"+batchHeaderHash, nil)
req := httptest.NewRequest(http.MethodGet, "/v2/batches/"+batchHeaderHash, nil)
r.ServeHTTP(w, req)
res := w.Result()
defer res.Body.Close()
Expand Down
Loading