Skip to content
Node: express()github.com/sahilkhaire/gox/http

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() *App

Compare: 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)

Back to http package overview

MIT Licensed · Built for Node.js developers moving to Go