mirror of
https://github.com/go-micro/go-micro.git
synced 2025-03-23 20:32:32 +02:00
53 lines
549 B
Markdown
53 lines
549 B
Markdown
# Beego API Example
|
|
|
|
This is an example of how to serve an API using beego
|
|
|
|
## Getting Started
|
|
|
|
### Run the Micro API
|
|
|
|
```
|
|
$ micro api --handler=http
|
|
```
|
|
|
|
### Run the Greeter Service
|
|
|
|
```shell
|
|
$ go run greeter/srv/main.go
|
|
```
|
|
|
|
### Run the Greeter API
|
|
|
|
```shell
|
|
$ go run beego.go
|
|
```
|
|
|
|
### Curl API
|
|
|
|
Test the index
|
|
|
|
```shell
|
|
curl http://localhost:8080/greeter
|
|
```
|
|
|
|
Output
|
|
|
|
```json
|
|
{
|
|
"message": "Hi, this is the Greeter API"
|
|
}
|
|
```
|
|
|
|
Test a resource
|
|
|
|
```shell
|
|
curl http://localhost:8080/greeter/asim
|
|
```
|
|
|
|
Output
|
|
```json
|
|
{
|
|
"msg": "Hello asim"
|
|
}
|
|
```
|