package main
import (
"github.com/zpatrick/fireball"
"net/http"
)
func index(c *fireball.Context) (fireball.Response, error) {
return fireball.NewResponse(200, []byte("Hello, World!"), nil), nil
}
func main() {
indexRoute := &fireball.Route{
Path: "/user/:id",
Handlers: fireball.Handlers{
"GET": index,
},
}
routes := []*fireball.Route{indexRoute}
app := fireball.NewApp(routes)
http.ListenAndServe(":8000", app)
}
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/user/100", func (w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome to my website!")
})
http.ListenAndServe(":80", nil)
}
$ curl http://localhost:8000/user/100/
Hello, World!
$ curl http://localhost:80/user/100/
404 page not found