This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker build -t gomongo:latest . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| EXPOSE 4400 | |
| CMD ["/app/main"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM alpine:3.16 | |
| WORKDIR /app | |
| COPY --from=builder /app/main . | |
| EXPOSE 4400 | |
| CMD ["/app/main"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM golang:1.19-alpine3.16 AS builder | |
| WORKDIR /app | |
| COPY . . | |
| RUN go build -o main main.go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const ( | |
| MONGO_URI = "mongodb://%s:%s@mongo:%v/golangmongo?authSource=admin" | |
| ) | |
| conn := fmt.Sprintf(MONGO_URI, "root", "rootpassword", 8081) | |
| // Access the client | |
| client, err := mongo.Connect(context.Background(), options.Client().ApplyURI(connectionURI)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| docker run --name mongo \ | |
| -p 8081:27017 \ | |
| -e MONGO_INITDB_ROOT_USERNAME=root \ | |
| -e MONGO_INITDB_ROOT_PASSWORD=rootpassword \ | |
| -d mongo:4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //How we will pas data between routes. | |
| // We can pass the data through bindings or better yet through our navigation functions | |
| Get.to(AppLinks.DASHBOARD, arguments: { "username": "John Doe" }); | |
| // Later in the dashboard controller accessing the arguments | |
| final args = Get.arguments; | |
| // Since the arguments are passed in as a map you can access the username using Map access functionalities that dart provides | |
| final username = args["username"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FavoritesBinding extends Bindings { | |
| @override | |
| void dependencies() { | |
| // Lazily inject the dependency and only use the dependency when needed. | |
| Get.lazyPut(() => FavoritesController()); | |
| } | |
| } | |
| /* | |
| ***Other Code** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Can be called within controllers | |
| void toDashboard() { | |
| Get.to( | |
| AppLinks.DASHBOARD, | |
| // Transition as a property. Different transitions can be applied. Such as | |
| // fade, | |
| // fadeIn, | |
| // rightToLeft, | |
| // leftToRight, | |
| // upToDown, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Other code | |
| GetPage( | |
| name: AppLinks.DASHBOARD, | |
| page: () => Dashboard(), | |
| middlewares: [ | |
| // Add here | |
| AuthGuard(), | |
| ], | |
| children: [ | |
| GetPage( |