Creating a New Service

  1. Create a directory/package that will contain your service (e.g. /internal/services/subscriptions)
  2. Make a file (e.g. /internal/services/subscriptions/ that gives an overview of your service along with a sample JSON response
  3. Create a models.go file in your new service package (e.g. /internal/services/subscriptions/models.go) and add in a constructor function that returns a struct that represents your service's JSON response populated with sane defaults
  4. Create a handlers.go file and implement whatever handler functions you need (return JSON using the models you created constructors for)
    • We use Echo for our HTTP routing so you'll need to make your handler functions match a structure similar to the one below:
    func hello(c echo.Context) error {
    return c.String(http.StatusOK, "Hello, World!")
  5. Make a service.go file in your new directory (e.g. /internal/services/subscriptions/service.go), implement GetHandlers() as defined in /internal/services/interface.go, and add your new handler functions (defined in handlers.go that you created in a step above) to the map that's returned
  6. Open cerulean.go in the root of the repository and add your new service to the svcs slice inside the New() function
    • This allows Echo to find and map our endpoints to HTTP listeners
  7. To finish things off, be a good person and create a handlers_test.go file and write a couple unit tests
Expand ▾ Collapse ▴




This section is empty.


This section is empty.


This section is empty.


type Handler

type Handler struct {
	// Verb is a string containing an HTTP verb value (
	Verb string
	Func echo.HandlerFunc

Handler is a helper struct that allows us to iterate over handlers to pass to Echo

type Service

type Service interface {
	// GetHandlers returns a map of key/value pairs where the key is the HTTP route and the value is a Handler struct (an Echo handler function along with its HTTP verb)
	GetHandlers() map[string]Handler

Service aims to help autodiscover our available services

Source Files


Path Synopsis