2019-01-28 04:36:44 +01:00
|
|
|
# Build RESTful API with the official MongoDB Go Driver and Iris
|
|
|
|
|
|
|
|
Article is coming soon, follow and stay tuned
|
|
|
|
|
|
|
|
- <https://medium.com/@kataras>
|
|
|
|
- <https://dev.to/kataras>
|
|
|
|
|
|
|
|
Read [the fully functional example](main.go).
|
|
|
|
|
2020-06-07 14:26:06 +02:00
|
|
|
## Run
|
|
|
|
|
|
|
|
### Docker
|
|
|
|
|
|
|
|
Install [Docker](https://www.docker.com/) and execute the command below
|
|
|
|
|
2019-01-28 04:36:44 +01:00
|
|
|
```sh
|
2020-06-07 14:26:06 +02:00
|
|
|
$ docker-compose up
|
2019-01-28 04:36:44 +01:00
|
|
|
```
|
|
|
|
|
2020-06-07 14:26:06 +02:00
|
|
|
### Manually
|
2019-01-28 04:36:44 +01:00
|
|
|
|
|
|
|
```sh
|
|
|
|
# .env file contents
|
|
|
|
PORT=8080
|
|
|
|
DSN=mongodb://localhost:27017
|
|
|
|
```
|
|
|
|
|
|
|
|
```sh
|
|
|
|
$ go run main.go
|
|
|
|
> 2019/01/28 05:17:59 Loading environment variables from file: .env
|
2020-06-07 14:26:06 +02:00
|
|
|
> 2019/01/28 05:17:59 ◽ Port=8080
|
2019-01-28 04:36:44 +01:00
|
|
|
> 2019/01/28 05:17:59 ◽ DSN=mongodb://localhost:27017
|
|
|
|
> Now listening on: http://localhost:8080
|
|
|
|
```
|
|
|
|
|
|
|
|
```sh
|
|
|
|
GET : http://localhost:8080/api/store/movies
|
|
|
|
POST : http://localhost:8080/api/store/movies
|
|
|
|
GET : http://localhost:8080/api/store/movies/{id}
|
|
|
|
PUT : http://localhost:8080/api/store/movies/{id}
|
|
|
|
DELETE : http://localhost:8080/api/store/movies/{id}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Screens
|
|
|
|
|
|
|
|
### Add a Movie
|
|
|
|

|
|
|
|
|
|
|
|
### Update a Movie
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
### Get all Movies
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
### Get a Movie by its ID
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
### Delete a Movie by its ID
|
|
|
|
|
|
|
|

|
|
|
|
|