Skip to content

Commit

Permalink
examples use v3
Browse files Browse the repository at this point in the history
  • Loading branch information
emicklei committed Oct 23, 2020
1 parent a0fdb2a commit 601692b
Show file tree
Hide file tree
Showing 64 changed files with 332 additions and 153 deletions.
10 changes: 5 additions & 5 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Change history of go-restful
# Change history of go-restful (v2 only)


## [v2.14.3] - 2020-08-31
## v2.14.3 - 2020-08-31
- Fixed duplicate compression in dispatch. #449


## [v2.14.2] - 2020-08-31
## v2.14.2 - 2020-08-31

- Added check on writer to prevent compression of response twice. #447

## [v2.14.0] - 2020-08-19
## v2.14.0 - 2020-08-19

- Enable content encoding on Handle and ServeHTTP (#446)
- List available representations in 406 body (#437)
- Convert to string using rune() (#443)

## [v2.13.0] - 2020-06-21
## v2.13.0 - 2020-06-21

- 405 Method Not Allowed must have Allow header (#436)
- add field allowedMethodsWithoutContentType (#424)
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ all: test

test:
go vet .
go test -cover -v .

ex:
cd examples && ls *.go | xargs go build -o /tmp/ignore
go test -cover -v .
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package for building REST-style Web Services using Google Go
[![GoDoc](https://godoc.org/github.com/emicklei/go-restful?status.svg)](https://pkg.go.dev/github.com/emicklei/go-restful)
[![codecov](https://codecov.io/gh/emicklei/go-restful/branch/master/graph/badge.svg)](https://codecov.io/gh/emicklei/go-restful)

- [Code examples](https://github.com/emicklei/go-restful/tree/master/examples)
- [Code examples using v3](https://github.com/emicklei/go-restful/tree/master/examples)

REST asks developers to use HTTP methods explicitly and in a way that's consistent with the protocol definition. This basic REST design principle establishes a one-to-one mapping between create, read, update, and delete (CRUD) operations and HTTP methods. According to this mapping:

Expand All @@ -21,23 +21,23 @@ REST asks developers to use HTTP methods explicitly and in a way that's consiste

### Usage

#### Without Go Modules
#### Using Go Modules

All versions up to `v2.*.*` (on the master) are not supporting Go modules.
As of version `v3.0.0` (on the v3 branch), this package supports Go modules.

```
import (
restful "github.com/emicklei/go-restful"
restful "github.com/emicklei/go-restful/v3"
)
```

#### Using Go Modules
#### Without Go Modules

As of version `v3.0.0` (on the v3 branch), this package supports Go modules.
All versions up to `v2.*.*` (on the master) are not supporting Go modules.

```
import (
restful "github.com/emicklei/go-restful/v3"
restful "github.com/emicklei/go-restful"
)
```

Expand Down
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## examples use v3 of the package
5 changes: 5 additions & 0 deletions examples/basicauth/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/basicauth

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/basicauth/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
"github.com/emicklei/go-restful"
"io"
"log"
"net/http"

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

// This example shows how to create a (Route) Filter that performs Basic Authentication on the Http request.
Expand Down
5 changes: 5 additions & 0 deletions examples/cors/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/cors

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/cors/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"
"net/http"

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

// Cross-origin resource sharing (CORS) is a mechanism that allows JavaScript on a web page
Expand Down
5 changes: 5 additions & 0 deletions examples/cpuprof/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/cpuprof

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/cpuprof/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package main

import (
"github.com/emicklei/go-restful"
"io"
"log"
"os"
"runtime/pprof"

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

// ProfilingService is a WebService that can start/stop a CPU profile and write results to a file
Expand Down
5 changes: 5 additions & 0 deletions examples/encoding/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/encoding

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/encoding/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package main

import (
"github.com/emicklei/go-restful"
"log"
"net/http"

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

type User struct {
Expand Down
5 changes: 5 additions & 0 deletions examples/filters/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/filters

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/filters/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
"github.com/emicklei/go-restful"
"log"
"net/http"
"time"

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

type User struct {
Expand Down
8 changes: 8 additions & 0 deletions examples/form/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/emicklei/go-restful/examples/form

go 1.14

require (
github.com/emicklei/go-restful/v3 v3.3.3 // indirect
github.com/gorilla/schema v1.2.0 // indirect
)
6 changes: 6 additions & 0 deletions examples/form/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/gorilla/schema v1.2.0 h1:YufUaxZYCKGFuAq3c96BOhjgd5nmXiOY9NGzF247Tsc=
github.com/gorilla/schema v1.2.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU=
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package main

import (
"fmt"
"github.com/emicklei/go-restful"
"github.com/gorilla/schema"
"io"
"log"
"net/http"

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

// This example shows how to handle a POST of a HTML form that uses the standard x-www-form-urlencoded content-type.
Expand Down
5 changes: 5 additions & 0 deletions examples/fulllog/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/fulllog

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/fulllog/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"log"
"net/http"

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

type User struct {
Expand Down
5 changes: 5 additions & 0 deletions examples/google-custom-method/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/google-custom-method

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/google-custom-method/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
. "github.com/emicklei/go-restful"
"io"
"log"
"net/http"

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

// This example shows how to create a Route with google custom method
Expand Down
5 changes: 5 additions & 0 deletions examples/hello/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/hello

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/hello/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
"github.com/emicklei/go-restful"
"io"
"log"
"net/http"

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

// This example shows the minimal code needed to get a restful.WebService working.
Expand Down
8 changes: 8 additions & 0 deletions examples/jwtauth/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/emicklei/go-restful/examples/jwtauth

go 1.14

require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.3.3 // indirect
)
7 changes: 7 additions & 0 deletions examples/jwtauth/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
github.com/dgrijalva/jwt-go v1.0.2 h1:KPldsxuKGsS2FPWsNeg9ZO18aCrGKujPoWXn2yo+KQM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package main

import (
"github.com/dgrijalva/jwt-go"
"github.com/emicklei/go-restful"
"io"
"log"
"net/http"
"strings"

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

// This example shows how to create a (Route) Filter that performs a JWT HS512 authentication.
Expand Down
2 changes: 1 addition & 1 deletion examples/msgpack/msgpack_entity.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package restPack

import (
restful "github.com/emicklei/go-restful"
restful "github.com/emicklei/go-restful/v3"
"gopkg.in/vmihailenco/msgpack.v2"
)

Expand Down
5 changes: 5 additions & 0 deletions examples/multi-container/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/multi-container

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/multi-container/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
"github.com/emicklei/go-restful"
"io"
"log"
"net/http"

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

// This example shows how to have a program with 2 WebServices containers
Expand Down
5 changes: 5 additions & 0 deletions examples/ncsa/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/ncsa

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/ncsa/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package main

import (
"github.com/emicklei/go-restful"
"io"
"log"
"net/http"
"os"
"strings"
"time"

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

// This example shows how to create a filter that produces log lines
Expand Down
5 changes: 5 additions & 0 deletions examples/nocache/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/emicklei/go-restful/examples/nocache

go 1.14

require github.com/emicklei/go-restful/v3 v3.3.3 // indirect
4 changes: 4 additions & 0 deletions examples/nocache/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github.com/emicklei/go-restful v1.1.3 h1:KOKLkEASmIa2roa2xEV6WkADqyWrok5dt3TOMMHF1fE=
github.com/emicklei/go-restful v2.14.3+incompatible h1:i59XyRHAxKCVBw3vHzQlpP/+pi89wH1v1HL+RKyVgxk=
github.com/emicklei/go-restful/v3 v3.3.3 h1:2WxjFb4b+Eik8vJ1saz3jbhKnt4xaFVn3N9uU3WXfLE=
github.com/emicklei/go-restful/v3 v3.3.3/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Loading

0 comments on commit 601692b

Please sign in to comment.