Documentation
¶
Index ¶
- Variables
- func Newmigrator(from, to *Version, avs []*Version, migrations Migrations) (*migrator, error)
- type GetUserVersionFunc
- type Migration
- type Migrations
- type RequestMigration
- func (rm *RequestMigration) RegisterMetrics(reg *prometheus.Registry)
- func (rm *RequestMigration) RegisterMigrations(migrations Migrations) error
- func (rm *RequestMigration) VersionRequest(r *http.Request) error
- func (rm *RequestMigration) VersionResponse(r *http.Request, body []byte) ([]byte, error)
- type RequestMigrationOptions
- type Version
- type VersionFormat
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Newmigrator ¶ added in v0.3.0
func Newmigrator(from, to *Version, avs []*Version, migrations Migrations) (*migrator, error)
Types ¶
type GetUserVersionFunc ¶ added in v0.3.0
type Migration ¶
type Migration interface {
Migrate(data []byte, header http.Header) ([]byte, http.Header, error)
ShouldMigrateConstraint(url *url.URL, method string, data []byte, isReq bool) bool
}
Migration is the core interface each transformation in every version needs to implement. It includes two predicate functions and two transformation functions.
type Migrations ¶
migrations := Migrations{
"2023-02-28": []Migration{
Migration{},
Migration{},
},
}
type RequestMigration ¶
type RequestMigration struct {
// contains filtered or unexported fields
}
RequestMigration is the exported type responsible for handling request migrations.
func NewRequestMigration ¶
func NewRequestMigration(opts *RequestMigrationOptions) (*RequestMigration, error)
func (*RequestMigration) RegisterMetrics ¶ added in v0.3.0
func (rm *RequestMigration) RegisterMetrics(reg *prometheus.Registry)
func (*RequestMigration) RegisterMigrations ¶
func (rm *RequestMigration) RegisterMigrations(migrations Migrations) error
func (*RequestMigration) VersionRequest ¶ added in v0.3.0
func (rm *RequestMigration) VersionRequest(r *http.Request) error
func (*RequestMigration) VersionResponse ¶ added in v0.3.0
type RequestMigrationOptions ¶
type RequestMigrationOptions struct {
// VersionHeader refers to the header value used to retrieve the request's
// version. If VersionHeader is empty, we call the GetUserVersionFunc to
// retrive the user's version.
VersionHeader string
// CurrentVersion refers to the API's most recent version. This value should
// map to the most recent version in the Migrations slice.
CurrentVersion string
// GetUserHeaderFunc is a function to retrieve the user's version. This is useful
// where the user has a persistent version that necessarily being available in the
// request.
GetUserVersionFunc GetUserVersionFunc
// VersionFormat is used to specify the versioning format. The two supported types
// are DateFormat and SemverFormat.
VersionFormat VersionFormat
}
RequestMigrationOptions is used to configure the RequestMigration type.
type Version ¶
type Version struct {
Format VersionFormat
Value interface{}
}
type VersionFormat ¶
type VersionFormat string
const ( SemverFormat VersionFormat = "semver" DateFormat VersionFormat = "date" )
Click to show internal directories.
Click to hide internal directories.