iris/_examples/tutorial/mongodb/README.md
Gerasimos (Makis) Maropoulos d0104defa8 create the new FileServer and HandleDir, deprecate the rest APIBuilder/Party static methods and more
relative: https://github.com/kataras/iris/issues/1283 and removing pongo2 from vendor: https://github.com/kataras/iris/issues/1284

Former-commit-id: 3ec57b349f99faca2b8e36d9f7252db0b6ea080d
2019-06-21 19:43:25 +03:00

59 lines
1.1 KiB
Markdown

# 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).
```sh
$ go get -u go.mongodb.org/mongo-driver/...
$ go get -u github.com/joho/godotenv
```
```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
> 2019/01/28 05:17:59 ◽ PORT=8080
> 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
![](0_create_movie.png)
### Update a Movie
![](1_update_movie.png)
### Get all Movies
![](2_get_all_movies.png)
### Get a Movie by its ID
![](3_get_movie.png)
### Delete a Movie by its ID
![](4_delete_movie.png)