JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • http.Server vs http.ListenAndServe

    Go SELF
    59 level,0 lecture
    We break down two approaches to starting an HTTP server in Go: a quick start via http.ListenAndServe and explicit configuration via http.Server. We build a mental model (“the server delivers requests to http.Handler”), discuss the role of ServeMux, the meaning of nil (as http.DefaultServeMux), the difference in controllability, and common mistakes with the ":8080" address and mixing routes.
    Open
  • Handlers and http.ServeMux: basic patterns

    Go SELF
    59 level,1 lecture
    We break down the basic mental model of HTTP in Go: how the server from net/http passes a request to http.ServeMux, how the http.Handler contract is defined via the ServeHTTP method, why the http.HandlerFunc adapter is needed, and how Handle and HandleFunc differ. At the end, we assemble a mini “task tracker” scaffold and pin down common mistakes (404/405, writing to stdout instead of http.ResponseWriter, confusion between routing and handling).
    Open
  • Safe request body reading in Go: limit, json.Decoder, and closing Body

    Go SELF
    59 level,2 lecture
    We break down the “hygiene” of reading an HTTP request body in Go: why r.Body is a stream ( io.ReadCloser) and “input from a stranger”, how to set a limit with http.MaxBytesReader, decode JSON in a streaming way with json.Decoder, enable strict mode with DisallowUnknownFields(), verify the “exactly one JSON” rule with io.EOF, and reliably close the body with defer Close(). At the end, there’s a ready-to-use helper and a list of typical mistakes.
    Open
  • JSON decoding and validation errors

    Go SELF
    59 level,3 lecture
    We break down why input errors are part of the HTTP API contract, how to keep a unified JSON response format by avoiding http.Error, how to build a stable error envelope, how decode errors differ from validation errors, and how to classify encoding/json errors in Go via errors.As/ errors.Is. At the end, we assemble a safe decodeJSON → validate pipeline for POST /tasks with a body size limit via http.MaxBytesReader.
    Open
  • Helpers writeJSON, writeError: a single path for JSON responses

    Go SELF
    59 level,4 lecture
    We break down how to establish a single HTTP response contract in Go using JSON: we write the helper writeJSON (status, Content-Type, buffering before serialization), lock down an error format via writeError and ErrorEnvelope, introduce HTTPError (public fields vs. an internal cause in Err), and centralize error handling with the appHandler adapter and its ServeHTTP method.
    Open
Learn
  • Registration
  • Java course
  • Help with tasks
  • Pricing
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Activities
Company
  • About us
  • Contacts
  • Reviews
  • FAQ
  • Support
JavaRushJavaRush — is an interactive online course for learning Java programming from scratch. It contains 1200 practical tasks with one-click solution checking, the necessary minimum of theory on Java basics, and motivating features that help you complete the course: games, quizzes, interesting projects and articles on effective learning and the career of a Java developer.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush
MastercardVisa
"Programmers are not born" © 2026 JavaRush