Skip to content

Commit

Permalink
examples to show differences #519
Browse files Browse the repository at this point in the history
  • Loading branch information
emicklei committed Apr 1, 2023
1 parent 9a53066 commit f0557cf
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/issue519/old39/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/emicklei/go-restful/examples/trimslash

go 1.14

require (
github.com/emicklei/go-restful/v3 v3.9.0
github.com/json-iterator/go v1.1.12 // indirect
)
17 changes: 17 additions & 0 deletions examples/issue519/old39/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE=
github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
30 changes: 30 additions & 0 deletions examples/issue519/old39/restful-hello-world.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"io"
"log"
"net/http"

restful "github.com/emicklei/go-restful/v3"
)

// This example shows the effect of the 3.9.0 behavior.
//
// curl http://localhost:8080/hello -> to you
// curl http://localhost:8080/hello/ -> to you

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

func hello1(req *restful.Request, resp *restful.Response) {
io.WriteString(resp, "world")
}

func hello2(req *restful.Request, resp *restful.Response) {
io.WriteString(resp, "to you")
}
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions examples/issue519/pathjoin/restful-hello-world.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"io"
"log"
"net/http"

restful "github.com/emicklei/go-restful/v3"
)

// This example shows the effect of the default MergePathStrategy (restful.PathJoinStrategy).
//
// curl http://localhost:8080/hello -> world
// curl http://localhost:8080/hello/ -> 404

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

func hello1(req *restful.Request, resp *restful.Response) {
io.WriteString(resp, "world")
}

func hello2(req *restful.Request, resp *restful.Response) {
io.WriteString(resp, "to you")
}
8 changes: 8 additions & 0 deletions examples/issue519/trimslash/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/emicklei/go-restful/examples/trimslash

go 1.14

require (
github.com/emicklei/go-restful/v3 v3.10.2
github.com/json-iterator/go v1.1.12 // indirect
)
17 changes: 17 additions & 0 deletions examples/issue519/trimslash/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE=
github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
File renamed without changes.

0 comments on commit f0557cf

Please sign in to comment.