Documentation
¶
Index ¶
- Variables
- func Newmigrator(from, to *Version, avs []*Version, migrations MigrationStore) (*migrator, error)
- type GetUserVersionFunc
- type Migration
- type MigrationStore
- type Migrations
- type RequestMigration
- func (rm *RequestMigration) RegisterMetrics(reg *prometheus.Registry)
- func (rm *RequestMigration) RegisterMigrations(migrations MigrationStore) error
- func (rm *RequestMigration) VersionRequest(r *http.Request, handler string) error
- func (rm *RequestMigration) VersionResponse(r *http.Request, body []byte, handler string) ([]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 MigrationStore) (*migrator, error)
Types ¶
type GetUserVersionFunc ¶ added in v0.3.0
type Migration ¶
Migration is the core interface each transformation in every version needs to implement. It includes two predicate functions and two transformation functions.
type MigrationStore ¶ added in v0.4.0
type MigrationStore map[string]Migrations
migrations := Migrations{
"2023-02-28": []Migration{
Migration{},
Migration{},
},
}
type Migrations ¶
type Migrations []Migration
Migrations is an array of migrations declared by each handler.
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 MigrationStore) error
func (*RequestMigration) VersionRequest ¶ added in v0.3.0
func (rm *RequestMigration) VersionRequest(r *http.Request, handler string) 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.