Building Dart APIs with Google Cloud Run
Learn how to build backend applications using Dart and Google Cloud Run. By Alhassan Kamil.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
Building Dart APIs with Google Cloud Run
30 mins
- Getting Started
- Running Your First Dart API Server
- Setting up a Google Cloud Project
- Creating the Project
- Creating a Service Account
- Setting up Billing
- An Overview of REST APIs
- Developing the API Endpoints
- Designing Endpoints
- Implementing the UserRoutes Endpoints
- Adding the NoteRoutes Endpoints
- Creating the AppRoutes Endpoints
- Testing the Routes
- Writing Controller Logic
- UserController
- NoteController
- Adding Middleware
- Response Headers Middleware
- Authentication Middleware
- Deploying Your Dart API on Google Cloud Run
- Installing Google Cloud CLI
- Configuring the Dockerfile
- Deploying to Cloud Run
- Accessing Your Dart REST API
- Where to Go From Here
Accessing Your Dart REST API
After deployment, gcloud displays a Service URL on the command line. Use that URL to send requests to the server. For example, to register a user:
curl -X POST -d '{"email": "newuser@example.com", "password": "pass1234"}' https://mnote-l5z2wfy3ia-ew.a.run.app/v1/users/register
Replace https://mnote-l5z2wfy3ia-ew.a.run.app
with the service URL gcloud displayed.
Where to Go From Here
You can download the complete project using the Download Materials button at the top or bottom of this tutorial.
You developed a good REST API using Dart in this tutorial. But you can improve it further by adding more features and security.
For further reading on Dart backend app development, you might want to try these:
- https://www.youtube.com/watch?v=v7FhaV9e3yY
- shelf, shelf_router, and other shelf-related packages
- httpserver
Do you have any questions, suggestions or improvements you made? Let us know in the comments section below.