

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to Learn HTTP Servers
incomplete
2: Goroutines in Servers
incomplete
3: Project Setup
incomplete
4: Server
incomplete
5: Fileservers
incomplete
6: Fileserver Quiz
incomplete
7: Serving Images
incomplete
8: Workflow Tips
incomplete
9: Custom Handlers
incomplete
10: Handler Review
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Servers are interesting because they're always running. A lot of the code we've written in Boot.dev up to this point has acted more like a command line tool: it runs, does its thing, and then exits.
Servers are different. They run forever, waiting for requests to come in, processing them, sending responses, and then waiting for the next request. If they didn't work this way, websites and apps would be down and unavailable all the time!
Debugging a CLI app is simple:
Debugging a server is a little different. The simplest way (minimal tooling) is to:
Make sure you're testing your server by hitting endpoints in the browser before submitting your answers.
I usually use a single command to build and run my servers, assuming I'm in my main package directory:
go run .
This builds the server and runs it in one command.
To stop the server, I use Ctrl+C. This sends a signal to the server, telling it to stop. The server then exits.
To start it again, I just run the same command.
Alternatively, you can compile a binary and run it instead
go build -o out && ./out
If you didn't know, you can continuously press the ↑ key on the command line to see the commands you've previously run. That way you don't need to re-type commands that you use often!