Skip to content
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
2 changes: 2 additions & 0 deletions daemon/algod/api/server/v2/generated/model/model_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ output-options:
integer: uint64
skip-prune: true
output: ./server/v2/generated/model/types.go
compatibility:
always-prefix-enum-values: true
28 changes: 14 additions & 14 deletions daemon/algod/api/server/v2/generated/model/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions daemon/algod/api/server/v2/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func (v2 *Handlers) ShutdownNode(ctx echo.Context, params model.ShutdownNodePara
// AccountInformation gets account information for a given account.
// (GET /v2/accounts/{address})
func (v2 *Handlers) AccountInformation(ctx echo.Context, address string, params model.AccountInformationParams) error {
handle, contentType, err := getCodecHandle((*model.Format)(params.Format))
handle, contentType, err := getCodecHandle((*string)(params.Format))
if err != nil {
return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log)
}
Expand Down Expand Up @@ -488,7 +488,7 @@ func (v2 *Handlers) basicAccountInformation(ctx echo.Context, addr basics.Addres
// AccountAssetInformation gets account information about a given asset.
// (GET /v2/accounts/{address}/assets/{asset-id})
func (v2 *Handlers) AccountAssetInformation(ctx echo.Context, address string, assetID uint64, params model.AccountAssetInformationParams) error {
handle, contentType, err := getCodecHandle((*model.Format)(params.Format))
handle, contentType, err := getCodecHandle((*string)(params.Format))
if err != nil {
return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log)
}
Expand Down Expand Up @@ -541,7 +541,7 @@ func (v2 *Handlers) AccountAssetInformation(ctx echo.Context, address string, as
// AccountApplicationInformation gets account information about a given app.
// (GET /v2/accounts/{address}/applications/{application-id})
func (v2 *Handlers) AccountApplicationInformation(ctx echo.Context, address string, applicationID uint64, params model.AccountApplicationInformationParams) error {
handle, contentType, err := getCodecHandle((*model.Format)(params.Format))
handle, contentType, err := getCodecHandle((*string)(params.Format))
if err != nil {
return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log)
}
Expand Down Expand Up @@ -598,7 +598,7 @@ func (v2 *Handlers) AccountApplicationInformation(ctx echo.Context, address stri
// GetBlock gets the block for the given round.
// (GET /v2/blocks/{round})
func (v2 *Handlers) GetBlock(ctx echo.Context, round uint64, params model.GetBlockParams) error {
handle, contentType, err := getCodecHandle((*model.Format)(params.Format))
handle, contentType, err := getCodecHandle((*string)(params.Format))
if err != nil {
return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log)
}
Expand Down Expand Up @@ -1187,7 +1187,7 @@ func (v2 *Handlers) PendingTransactionInformation(ctx echo.Context, txid string,
response.Inners = convertInners(&txn)
}

handle, contentType, err := getCodecHandle((*model.Format)(params.Format))
handle, contentType, err := getCodecHandle((*string)(params.Format))
if err != nil {
return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log)
}
Expand Down Expand Up @@ -1221,7 +1221,7 @@ func (v2 *Handlers) getPendingTransactions(ctx echo.Context, max *uint64, format
addrPtr = &addr
}

handle, contentType, err := getCodecHandle((*model.Format)(format))
handle, contentType, err := getCodecHandle(format)
if err != nil {
return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log)
}
Expand Down
10 changes: 5 additions & 5 deletions daemon/algod/api/server/v2/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,16 @@ func computeAppIndexFromTxn(tx node.TxnWithStatus, l LedgerForAPI) *uint64 {
}

// getCodecHandle converts a format string into the encoder + content type
func getCodecHandle(formatPtr *model.Format) (codec.Handle, string, error) {
format := model.Json
func getCodecHandle(formatPtr *string) (codec.Handle, string, error) {
format := "json"
if formatPtr != nil {
format = model.PendingTransactionInformationParamsFormat(strings.ToLower(string(*formatPtr)))
format = strings.ToLower(*formatPtr)
}

switch format {
case model.Json:
case "json":
return protocol.JSONStrictHandle, "application/json", nil
case model.Msgpack:
case "msgpack":
fallthrough
case "msgp":
return protocol.CodecHandle, "application/msgpack", nil
Expand Down