Categorygithub.com/cosimocollini/gowebserver
repositorypackage
0.0.0-20240529195241-8aee95c2c10b
Repository: https://github.com/cosimocollini/gowebserver.git
Documentation: pkg.go.dev

# README

Go Webserver Chirps

This is a simple project aimed at practicing my Go skills, created by Boot.dev.

The project shows how to design a web server that serves static files and exposes APIs

Build and start project

go build -o out && ./out

Open Endpoints

Open endpoints require no Authentication.

Reset visits counter and metrics

GET /api/reset
Parameters
nametypedata typedescription
Nonerequiredobject (JSON)N/A
Responses
http codecontent-typeresponse
200text/plain;charset=UTF-8Hits reset to 0
GET /admin/metrics
Parameters
nametypedata typedescription
Nonerequiredobject (JSON)N/A
Responses
http codecontent-typeresponse
200text/html;charset=UTF-8<html><body><h1>Welcome, Chirpy Admin</h1><p>Chirpy has been visited %d times!</p></body></html>

Auth and token

Closed endpoints require a valid Token to be included in the header of the request.

POST /api/login
Parameters
nametypedata typedescription
EmailrequiredstringN/A
PasswordrequiredstringN/A
Responses
http codecontent-typeresponse
200application/json``
401text/plain;charset=UTF-8Invalid password