Skip to content

subomi/requestmigrations

Repository files navigation

requestmigrations
Go Reference

requestmigrations is a Golang implementation of rolling versions for REST APIs. It's a port of the Ruby implementation by ezekg. We use it in production at Convoy.

Note

This README describes v2 of requestmigrations. For older versions, please check the release tags.

Built By

Sponsored by Convoy

Features

  • API Versioning with date and semver versioning support.
  • Prometheus Instrumentation to track and optimize slow transformations.
  • Type-based migration system.

Installation

 go get github.com/subomi/requestmigrations/v2

Usage

RequestMigrations introduces a type-based migration system. Instead of defining migrations per API handler, migrations are now defined per Go type.

package main

import (
	rms "github.com/subomi/requestmigrations/v2"
)

func main() {
    rm, _ := rms.NewRequestMigration(&rms.RequestMigrationOptions{
        VersionHeader:  "X-API-Version",
        CurrentVersion: "2024-01-01",
        VersionFormat:  rms.DateFormat,
    })

    // Register migrations for a specific type
    rms.Register[User](rm, "2024-01-01", &UserMigration{})
}

Example

Check the examples directory for full examples.

License

MIT License

About

requestmigrations implements rolling versions for REST APIs.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages