Composable and minimalistic HTTP router for building Go backend applications inspired by Plug.
Require go 1.21.0
or higher.
go get github.com/nicolito128/plugo
package main
import (
"fmt"
"log"
"net/http"
"github.com/nicolito128/plugo"
)
func main() {
router := plugo.New()
router.Get("/", hello_world)
fmt.Println("Server running at http://localhost:8080/ - Press CTRL+C to exit")
log.Fatal(http.ListenAndServe(":8080", router))
}
func hello_world(w http.ResponseWriter, r *http.Request) {
conn := plugo.NewConnection(w, r)
if err := conn.String(http.StatusOK, "Hello, Plugo World!"); err != nil {
panic(err)
}
}