package main
import (
"fmt"
"github.com/kn9ts/frodo"
"net/http"
)
func one(w http.ResponseWriter, r *frodo.Request) {
fmt.Println("Hello, am the 1st middleware!")
}
func main() {
app := frodo.New()
app.RedirectTrailingSlash = false
app.Get("/hello/:name", one)
app.Serve() //3102
}
$ curl -v http://localhost:3102/hello/
HTTP/1.1 200 OK
Content-Length: 0
$ curl -v http://localhost:3102/hello/frodo/
HTTP/1.1 200 OK
Content-Length: 0
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/hello/frodo", func (w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome to my website!")
})
http.ListenAndServe(":3102", nil)
}
$ curl -v http://localhost/hello/
HTTP/1.1 404 Not Found
$ curl -v http://localhost/hello/frodo/
HTTP/1.1 404 Not Found
$ curl -v http://localhost:3102/hello/
HTTP/1.1 200 OK
Content-Length: 0
$ curl -v http://localhost:3102/hello/frodo/
HTTP/1.1 200 OK
Content-Length: 0
$ curl -v http://localhost/hello/
HTTP/1.1 404 Not Found
$ curl -v http://localhost/hello/frodo/
HTTP/1.1 404 Not Found