package main
import (
"compress/gzip"
"context"
"fmt"
"net/http"
"github.com/pilwon/gogo"
_ "github.com/pilwon/gogo/router/httprouter"
)
func main() {
app := gogo.New()
app.Use(NewRecoveryMiddleware())
app.Use(NewGorillaLogger())
app.Use(NewGzipMiddleware(gzip.DefaultCompression))
app.Use(NewStaticMiddleware(http.Dir("static")))
app.Get("/", func(c context.Context, w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "gogo server\n")
})
app.Get("/hello/:name", func(c context.Context, w http.ResponseWriter, r *http.Request) {
name, _ := gogo.Param(c, "name")
fmt.Fprintf(w, "Hello, %s!\n", name)
})
app.Run(":8080")
}
pilwon/gogo
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
gogo
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published