CodeRigor

COURSE / REAL PRACTICE

Build your first HTTP service

Build a standard-library Go notes API with explicit server configuration, bounded JSON, deliberate routes, repository boundaries and handler tests.

Lessons & exercises7 authored lessons3 units
Start with the first lesson.

Read the explanation and diagrams, then work through the practice. Your browser profile supplies your saved progress.

What you’ll work toward

Build and test a working JSON notes API, then run the supplied loopback server with explicit timeouts and graceful shutdown. Hosted exercises use request/response recorders without opening sockets.

Read an explanation, inspect the diagrams and work through the available checks, debugging exercises and builds. Feedback and prerequisite links guide the next step.

Before you start

This course builds on these skills:

Individual lessons can add prerequisites. Your lesson progress shows your actual readiness.

A look inside the first lesson

Configure the server and own its lifetime

Go
package main
import ("fmt";"net/http";"time")
func main(){
h:=http.HandlerFunc(func(w http.ResponseWriter,r *http.Request){w.WriteHeader(202)})
s:=&http.Server{Addr:"127.0.0.1:0",Handler:h,ReadHeaderTimeout:2*time.Second}
fmt.Println(s.Addr,s.ReadHeaderTimeout)
}

Your lesson sequence

Follow the same units and lessons in either view. Prerequisite links and your practice progress stay with each lesson.

UNIT 013 lessons Server, routes and bounded inputs
  1. LESSON 01.01

    Configure the server and own its lifetime

    Use an explicit handler, loopback address and finite server limits; distinguish configuration, serving and graceful shutdown.

    Open lesson
  2. LESSON 01.02

    Route methods and canonical paths deliberately

    Separate missing routes from unsupported methods, preserve an explicit Allow contract and reject ambiguous note identifiers.

    Open lesson
  3. LESSON 01.03

    Decode bounded JSON before changing state

    Read at most a declared body bound, reject duplicate/unknown fields and validate a trimmed title without leaking partial input.

    Open lesson
UNIT 023 lessons Responses, storage and evidence
  1. LESSON 02.01

    Commit one consistent JSON response

    Encode before committing headers, preserve JSON and length metadata, suppress HEAD bodies and propagate write failures.

    Open lesson
  2. LESSON 02.02

    Put mutable state behind a repository boundary

    Use a synchronized bounded in-memory store with monotonic IDs, stable ordering and snapshots that cannot mutate stored notes.

    Open lesson
  3. LESSON 02.03

    Test the whole exchange, not just the status

    Build a read-only handler probe that checks status, headers and exact fixture bodies, and prove it rejects plausible broken handlers.

    Open lesson
UNIT 031 lesson The complete notes service
  1. LESSON 03.01

    Build and run the complete notes API

    Integrate route, input, response and repository boundaries, then run a downloadable loopback server with deterministic fixtures and cleanup.

    Open lesson