Skip to content

Commit

Permalink
update examples for api change
Browse files Browse the repository at this point in the history
  • Loading branch information
asim committed Nov 20, 2018
1 parent a67070e commit 1e3669e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 33 deletions.
22 changes: 11 additions & 11 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# API

This repo contains examples for serving microservices via the micro api.
This repo contains examples for using the micro api.

The [micro api](https://github.com/micro/micro/tree/master/api) is an API gateway which serves HTTP and routes to RPC based services.
In the micro ecosystem we logically separate concerns via architecture and tooling. Read more on buiding an API layer of services
in the [architecture blog post](https://micro.mu/blog/2016/04/18/micro-architecture.html).
## Overview

The [micro api](https://github.com/micro/micro/tree/master/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=`.
can be set via the flag `--handler=`. The default handler is "rpc".

## Contents

- default - an api using the default micro api request handler
- proxy - an api using the http proxy handler
- rpc - an api using standard go-micro rpc
- meta - an api which specifies its api endpoints
- 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

## Deps
## Dependencies

Service discovery is required for all services. Default is Consul or MDNS. You can also use plugins from
[micro/plugins](https://github.com/micro/go-plugins).
Expand All @@ -37,7 +37,7 @@ consul agent -dev

## Request Mapping

### API + RPC
### API/RPC

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

Expand Down
10 changes: 5 additions & 5 deletions api/default/README.md → api/api/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Default API
# API

This example makes use of the default micro API request handler.
This example makes use of the "api" handler.

The api expects you use the [api.Request/Response](https://github.com/micro/go-api/blob/master/proto/api.proto) protos.

The default micro api request handler gives you full control over the http request and response while still leveraging RPC and
The micro api request handler gives you full control over the http request and response while still leveraging RPC and
any transport plugins that use other protocols beyond http in your stack such as grpc, nats, kafka.

## Usage

Run the micro API

```
micro api
micro api --handler=api
```

Run this example

```
go run default.go
go run api.go
```

Make a GET request to /example/call which will call go.micro.api.example Example.Call
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 1 addition & 17 deletions greeter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ go run api/api.go

Run the micro API
```shell
micro api
micro api --handler=api
```

Call go.micro.api.greeter via API
Expand All @@ -63,22 +63,6 @@ curl http://localhost:8080/greeter/say/hello?name=John

Examples of other API handlers can be found in the API directory.

## Sidecar

The sidecar is a language agnostic RPC proxy.

Run the micro sidecar
```shell
micro sidecar
```

Call go.micro.srv.greeter via sidecar
```shell
curl -H 'Content-Type: application/json' -d '{"name": "john"}' http://localhost:8081/greeter/say/hello
```

The sidecar provides all the features of go-micro as a HTTP API. Learn more at [micro/car](https://github.com/micro/micro/tree/master/car).

## Web

The micro web is a web dashboard and reverse proxy to run web apps as microservices.
Expand Down

0 comments on commit 1e3669e

Please sign in to comment.