Maintaining API Versions in Go

Context

Problem

  • Maintain old versions without cluttering/blocking new developments.
  • Update our testing to ensure old versions work.

Solution

Version Migration

2018-03-09 - Rename User.FullName -> User.Name
2018-02-09 - Add User.CreatedAt
2018-01-09
func getUserRoute(req, res)
switch (req.version) {
case "2018-03-09":
user["name"] = user["full_name"]
break
case "2018-02-09":
user["created_at"] = user.date()
break
case "2018-01-09":
break
// ...
}
return res.write(user)
}

Testing

Conculusion

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Designing a knowledge tree for self-learning — learning fast in a practical way

Ripple Animation in Flutter a Simple app(Task 6)

HP printer error codes — Issue and how to resolve it

HP printer error codes - Issue and how to resolve it

Django vs flask and advanced scalable python web development in 2019

advance scaleable web development using flask

AWS Associate Cloud Architect Exam Preperation

Automating Amazon Ads Reporting using Python and the Amazon Ads API

From Zero to HA — Part One

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Steve Kaliski

Steve Kaliski

More from Medium

Echo 101: Get service metadata from Web UI

Concurrency in Golang

GoLang — Concurrency (goroutine, channel)

Go Simplified: Scheduling and Context Switching