Skip to content

Commit

Permalink
Render MessagePack
Browse files Browse the repository at this point in the history
  • Loading branch information
bbengfort committed Nov 26, 2024
1 parent 2d7d5b7 commit 1325366
Show file tree
Hide file tree
Showing 15 changed files with 1,785 additions and 53 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/rotationalio/confire v1.1.0
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.9.0
github.com/tinylib/msgp v1.2.4
github.com/urfave/cli/v2 v2.27.5
)

Expand All @@ -19,6 +20,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c h1:dAMKvw0MlJT1GshSTtih8C2gDs04w8dReiOGXrGLNoY=
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand All @@ -34,6 +36,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tinylib/msgp v1.2.4 h1:yLFeUGostXXSGW5vxfT5dXG/qzkn4schv2I7at5+hVU=
github.com/tinylib/msgp v1.2.4/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
Expand Down
31 changes: 22 additions & 9 deletions pkg/api/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package api

import "context"

//go:generate msgp

//===========================================================================
// Service Interface
//===========================================================================
Expand All @@ -17,21 +19,32 @@ type Client interface {

// Reply contains standard fields that are used for generic API responses and errors.
type Reply struct {
Success bool `json:"success"`
Error string `json:"error,omitempty"`
ErrorDetail ErrorDetail `json:"errors,omitempty"`
Success bool `json:"success" msg:"success"`
Error string `json:"error,omitempty" msg:"error,omitempty"`
ErrorDetail ErrorDetail `json:"errors,omitempty" msg:"errors,omitempty"`
}

// Returned on status requests.
type StatusReply struct {
Status string `json:"status"`
Uptime string `json:"uptime,omitempty"`
Version string `json:"version,omitempty"`
Status string `json:"status" msg:"status"`
Uptime string `json:"uptime,omitempty" msg:"uptime,omitempty"`
Version string `json:"version,omitempty" msg:"version,omitempty"`
}

// PageQuery manages paginated list requests.
type PageQuery struct {
PageSize int `json:"page_size,omitempty" url:"page_size,omitempty" form:"page_size"`
NextPageToken string `json:"next_page_token,omitempty" url:"next_page_token,omitempty" form:"next_page_token"`
PrevPageToken string `json:"prev_page_token,omitempty" url:"prev_page_token,omitempty" form:"prev_page_token"`
PageSize int `json:"page_size,omitempty" msg:"page_size,omitempty" url:"page_size,omitempty" form:"page_size"`
NextPageToken string `json:"next_page_token,omitempty" msg:"next_page_token,omitempty" url:"next_page_token,omitempty" form:"next_page_token"`
PrevPageToken string `json:"prev_page_token,omitempty" msg:"prev_page_token,omitempty" url:"prev_page_token,omitempty" form:"prev_page_token"`
}

//===========================================================================
// Detail Error
//===========================================================================

type ErrorDetail []*DetailError

type DetailError struct {
Field string `json:"field" msg:"field"`
Error string `json:"error" msg:"error"`
}
Loading

0 comments on commit 1325366

Please sign in to comment.