Skip to content

Commit

Permalink
more route examples #519
Browse files Browse the repository at this point in the history
  • Loading branch information
emicklei committed Apr 1, 2023
1 parent f0557cf commit abc6f6e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/issue519/trimslash/restful-hello-world.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ import (
//
// curl http://localhost:8080/hello -> world
// curl http://localhost:8080/hello/ -> to you
// curl http://localhost:8080/hi -> world
// curl http://localhost:8080/hi/ -> 404
// curl http://localhost:8080/hey -> to you
// curl http://localhost:8080/hey/ -> 404

func main() {
restful.MergePathStrategy = restful.TrimSlashStrategy
ws := new(restful.WebService)
ws.Route(ws.GET("/hello").To(hello1))
ws.Route(ws.GET("/hello/").To(hello2))
ws.Route(ws.GET("/hi").To(hello1))
ws.Route(ws.GET("/hey").To(hello2))
restful.Add(ws)
log.Fatal(http.ListenAndServe(":8080", nil))
}
Expand Down

0 comments on commit abc6f6e

Please sign in to comment.