Go: Serve HTTP JSON API for in-memory objects (DevLog #002)
Review the source code for MemUI's HTTP JSON API Server. Includes using net/http package, JSON Encode, and step-by-step tutorial.
In yesterday's DevLog, we reviewed the source code for MemUI's HTTP JSON API Server. At the end of this page, you can find the recording of this video. I also published the step-by-step guide explaining each part in detail.
In this video:
- Serve an HTTP server with a standard "net/http" package;
- Index API to list all internal types;
- Explore API to list all objects for a selected type;
- Marshal to JSON;
Demo of the final result:
API Changes
We plan to add a new ServerHTTP
method to the MemUI type so clients can execute it and serve a JSON API:
Which starts the following HTTP server:
Please note that here *main.Department
is the name of the pointer type.
YouTube Video
📚
Check the following course section for a step-by-step guide to creating HTTP Server with a JSON API.
👉🏼 Extended version of the YouTube Video
👉🏼 Extended version of the YouTube Video
About DevLogs
DevLog series is my attempt to post a new coding video every day! It is like Daily Standup in s Scrum team where I share a) What I worked on Yesterday? b) What's a plan for today? and c) Are there any blockers or learning points? Learn more: All DevLogs.