Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Building a HTTP/2 Server wi | Go Programming Bootcamp lesson | BraveProgrammer
  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 46 of 60

·Go

Building a HTTP/2 Server with TLS

20 minutes

Course progress77%

HTTP/2 + TLS

This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.

Go enables HTTP/2 automatically when serving over TLS.

cert, _ := tls.LoadX509KeyPair("server.crt", "server.key")
server := &http.Server{
    Addr:    ":443",
    Handler: mux,
    TLSConfig: &tls.Config{MinVersion: tls.VersionTLS12},
}
log.Fatal(server.ListenAndServeTLS(, )) 
""
""
// cert/key already in TLSConfig

ALPN negotiation

The client and server negotiate HTTP/2 via ALPN during the TLS handshake.

Testing locally

$ mkcert -install
$ mkcert localhost

Then run the server with the generated localhost+2.pem and localhost+2-key.pem.

Info

HTTP/2 improves multiplexing and header compression – great for APIs.
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from Go Programming BootcampBrowse activities
Previous lessonEmbedding a SQLite Database with `modernc.org/sqlite`Continue to lesson 47Deploying Go Services to Docker & KubernetesBack to Go Programming Bootcamp curriculum