Skip to content

Commit

Permalink
feat(example): Update for new version
Browse files Browse the repository at this point in the history
Update the example code to be compatible with the latest version
  • Loading branch information
cpf2021-gif committed Jan 23, 2024
1 parent 3d3939e commit 9a55d32
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions test/example.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package main

import (
"fmt"
"net/http"

"github.com/cpf2021-gif/gow"
)

func main() {
r := gow.New()
r.GET("/", func(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "URL.Path = %q\n", req.URL.Path)

r.GET("/", func(c *gow.Context) {
c.HTML(http.StatusOK, "<h1>Hello gow</h1>")
})

r.GET("/hello", func(c *gow.Context) {
c.String(http.StatusOK, "hello, Have a nice day!\n")
})

r.GET("/hello", func(w http.ResponseWriter, req *http.Request) {
for k, v := range req.Header {
fmt.Fprintf(w, "Header[%q] = %q\n", k, v)
}
r.POST("/login", func(c *gow.Context) {
c.JSON(http.StatusOK, gow.H{
"username": c.PostForm("username"),
"password": c.PostForm("password"),
})
})

r.Run(":9999")
Expand Down

0 comments on commit 9a55d32

Please sign in to comment.