Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
api update readme Jan 9, 2019
meta fix meta example Aug 24, 2018
proxy update handler to http Jun 19, 2018
rpc protoc-gen-micro was updated Apr 25, 2018 Update readmes to remove consul Jan 15, 2019


This repo contains examples for using the micro api.


The micro api is an API gateway which serves HTTP and routes dynamically based on service discovery.

The micro api by default serves the namespace go.micro.api. Our service names include this plus a unique name e.g go.micro.api.example. You can change the namespace via the flag --namespace=.

The micro api has a number of different handlers which lets you define what kind of API services you want. See examples below. The handler can be set via the flag --handler=. The default handler is "rpc".


  • api - an rpc handler that provides the entire http headers and request
  • proxy - use the api as a http reverse proxy
  • rpc - make an rpc request to a go-micro app
  • meta - specify which handler to use via configuration in code

Request Mapping


Micro maps http paths to rpc services. The mapping table can be seen below.

The default namespace for the api is go.micro.api but you can set your own namespace via --namespace.

URLs are mapped as follows:

Path Service Method
/foo/bar Foo.Bar
/foo/bar/baz Bar.Baz
/foo/bar/baz/cat Baz.Cat

Versioned API URLs can easily be mapped to service names:

Path Service Method
/foo/bar Foo.Bar
/v1/foo/bar Foo.Bar
/v1/foo/bar/baz Bar.Baz
/v2/foo/bar Foo.Bar
/v2/foo/bar/baz Bar.Baz

Proxy Mapping

Starting the API with --handler=http will reverse proxy requests to backend services within the served API namespace (default: go.micro.api).


Path Service Service Path
/greeter go.micro.api.greeter /greeter
/greeter/:name go.micro.api.greeter /greeter/:name