godeps: update go-restful

This commit is contained in:
Mike Danese 2016-08-18 11:24:14 -07:00
parent 2166ce2fdc
commit 5bc62260db
7 changed files with 37 additions and 25 deletions

9
Godeps/Godeps.json generated
View File

@ -852,18 +852,15 @@
},
{
"ImportPath": "github.com/emicklei/go-restful",
"Comment": "v1.2-66-gc4afa8e",
"Rev": "c4afa8e5421428d584b32d36d7b35f2c9ae5f823"
"Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
},
{
"ImportPath": "github.com/emicklei/go-restful/log",
"Comment": "v1.2-66-gc4afa8e",
"Rev": "c4afa8e5421428d584b32d36d7b35f2c9ae5f823"
"Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
},
{
"ImportPath": "github.com/emicklei/go-restful/swagger",
"Comment": "v1.2-66-gc4afa8e",
"Rev": "c4afa8e5421428d584b32d36d7b35f2c9ae5f823"
"Rev": "89ef8af493ab468a45a42bb0d89a06fccdd2fb22"
},
{
"ImportPath": "github.com/evanphx/json-patch",

View File

@ -61,8 +61,8 @@ func (u UserResource) findUser(request *restful.Request, response *restful.Respo
- [Documentation on godoc.org](http://godoc.org/github.com/emicklei/go-restful)
- [Code examples](https://github.com/emicklei/go-restful/tree/master/examples)
- [Example posted on blog](http://ernestmicklei.com/2012/11/24/go-restful-first-working-example/)
- [Design explained on blog](http://ernestmicklei.com/2012/11/11/go-restful-api-design/)
- [Example posted on blog](http://ernestmicklei.com/2012/11/go-restful-first-working-example/)
- [Design explained on blog](http://ernestmicklei.com/2012/11/go-restful-api-design/)
- [sourcegraph](https://sourcegraph.com/github.com/emicklei/go-restful)
- [gopkg.in](https://gopkg.in/emicklei/go-restful.v1)
- [showcase: Mora - MongoDB REST Api server](https://github.com/emicklei/mora)

View File

@ -283,12 +283,12 @@ func fixedPrefixPath(pathspec string) string {
}
// ServeHTTP implements net/http.Handler therefore a Container can be a Handler in a http.Server
func (c Container) ServeHTTP(httpwriter http.ResponseWriter, httpRequest *http.Request) {
func (c *Container) ServeHTTP(httpwriter http.ResponseWriter, httpRequest *http.Request) {
c.ServeMux.ServeHTTP(httpwriter, httpRequest)
}
// Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics.
func (c Container) Handle(pattern string, handler http.Handler) {
func (c *Container) Handle(pattern string, handler http.Handler) {
c.ServeMux.Handle(pattern, handler)
}
@ -318,7 +318,7 @@ func (c *Container) Filter(filter FilterFunction) {
}
// RegisteredWebServices returns the collections of added WebServices
func (c Container) RegisteredWebServices() []*WebService {
func (c *Container) RegisteredWebServices() []*WebService {
c.webServicesLock.RLock()
defer c.webServicesLock.RUnlock()
result := make([]*WebService, len(c.webServices))
@ -329,7 +329,7 @@ func (c Container) RegisteredWebServices() []*WebService {
}
// computeAllowedMethods returns a list of HTTP methods that are valid for a Request
func (c Container) computeAllowedMethods(req *Request) []string {
func (c *Container) computeAllowedMethods(req *Request) []string {
// Go through all RegisteredWebServices() and all its Routes to collect the options
methods := []string{}
requestPath := req.Request.URL.Path

View File

@ -1,9 +1,10 @@
cd examples
ls *.go | xargs -I {} go build -o /tmp/ignore {}
cd ..
go fmt ...swagger && \
go test -test.v ...restful && \
go test -test.v ...swagger && \
go vet ...restful && \
go fmt ...swagger && \
go install ...swagger && \
go fmt ...restful && \
go test -test.v ...restful && \
go install ...restful
go install ...restful
cd examples
ls *.go | xargs -I {} go build -o /tmp/ignore {}
cd ..

View File

@ -51,6 +51,14 @@ func (b modelBuilder) addModel(st reflect.Type, nameOverride string) *Model {
if b.isPrimitiveType(modelName) {
return nil
}
// golang encoding/json packages says array and slice values encode as
// JSON arrays, except that []byte encodes as a base64-encoded string.
// If we see a []byte here, treat it at as a primitive type (string)
// and deal with it in buildArrayTypeProperty.
if (st.Kind() == reflect.Slice || st.Kind() == reflect.Array) &&
st.Elem().Kind() == reflect.Uint8 {
return nil
}
// see if we already have visited this model
if _, ok := b.Models.At(modelName); ok {
return nil
@ -276,6 +284,11 @@ func (b modelBuilder) buildArrayTypeProperty(field reflect.StructField, jsonName
return jsonName, prop
}
fieldType := field.Type
if fieldType.Elem().Kind() == reflect.Uint8 {
stringt := "string"
prop.Type = &stringt
return jsonName, prop
}
var pType = "array"
prop.Type = &pType
isPrimitive := b.isPrimitiveType(fieldType.Elem().Name())

View File

@ -118,6 +118,7 @@ type ApiDeclaration struct {
ApiVersion string `json:"apiVersion"`
BasePath string `json:"basePath"`
ResourcePath string `json:"resourcePath"` // must start with /
Info Info `json:"info"`
Apis []Api `json:"apis,omitempty"`
Models ModelList `json:"models,omitempty"`
Produces []string `json:"produces,omitempty"`

View File

@ -1,7 +1,7 @@
package restful
import (
"fmt"
"errors"
"os"
"sync"
@ -51,7 +51,7 @@ func (w *WebService) ApiVersion(apiVersion string) *WebService {
}
// Version returns the API version for documentation purposes.
func (w WebService) Version() string { return w.apiVersion }
func (w *WebService) Version() string { return w.apiVersion }
// Path specifies the root URL template path of the WebService.
// All Routes will be relative to this path.
@ -155,7 +155,7 @@ func (w *WebService) Route(builder *RouteBuilder) *WebService {
// RemoveRoute removes the specified route, looks for something that matches 'path' and 'method'
func (w *WebService) RemoveRoute(path, method string) error {
if !w.dynamicRoutes {
return fmt.Errorf("dynamic routes are not enabled.")
return errors.New("dynamic routes are not enabled.")
}
w.routesLock.Lock()
defer w.routesLock.Unlock()
@ -192,7 +192,7 @@ func (w *WebService) Consumes(accepts ...string) *WebService {
}
// Routes returns the Routes associated with this WebService
func (w WebService) Routes() []Route {
func (w *WebService) Routes() []Route {
if !w.dynamicRoutes {
return w.routes
}
@ -207,12 +207,12 @@ func (w WebService) Routes() []Route {
}
// RootPath returns the RootPath associated with this WebService. Default "/"
func (w WebService) RootPath() string {
func (w *WebService) RootPath() string {
return w.rootPath
}
// PathParameters return the path parameter names for (shared amoung its Routes)
func (w WebService) PathParameters() []*Parameter {
func (w *WebService) PathParameters() []*Parameter {
return w.pathParameters
}
@ -229,7 +229,7 @@ func (w *WebService) Doc(plainText string) *WebService {
}
// Documentation returns it.
func (w WebService) Documentation() string {
func (w *WebService) Documentation() string {
return w.documentation
}