App.New
Overview
Creates a new Express-style application with chi router underneath. Register routes with Get/Post/… and global middleware with Use.
If you are coming from Node.js, the closest pattern is express().
Method on App — call it on a value of that type after constructing or receiving one from a constructor.
Signature
go
func New() *AppCompare: Node.js · Standard Go · gox
js
const app = express();go
mux := http.NewServeMux()
http.ListenAndServe(":8080", mux)go
import "github.com/sahilkhaire/gox/http"
app := goxhttp.New()Example
go
import "github.com/sahilkhaire/gox/http"
app := goxhttp.New()Tips
Stack Logger, Recover, and Security middleware like you would morgan + helmet in Express. See the HTTP guide.
Standard library alternative
Use the standard library directly:
go
mux := http.NewServeMux()
http.ListenAndServe(":8080", mux)