type RouteBuilder … // Do evaluates each argument with the RouteBuilder itself. // This allows you to follow DRY principles without breaking the fluent programming style. // Example: // // ws.Route(ws.DELETE("/{name}").To(t.deletePerson).Do(Returns200, Returns500)) // // func Returns500(b *RouteBuilder) { // b.Returns(500, "Internal Server Error", restful.ServiceError{}) // } func (b *RouteBuilder) Do(oneArgBlocks ...func(*RouteBuilder)) *RouteBuilder { … } // To bind the route to a function. // If this route is matched with the incoming Http Request then call this function with the *Request,*Response pair. Required. func (b *RouteBuilder) To(function RouteFunction) *RouteBuilder { … } // Method specifies what HTTP method to match. Required. func (b *RouteBuilder) Method(method string) *RouteBuilder { … } // Produces specifies what MIME types can be produced ; the matched one will appear in the Content-Type Http header. func (b *RouteBuilder) Produces(mimeTypes ...string) *RouteBuilder { … } // Consumes specifies what MIME types can be consumes ; the Accept Http header must matched any of these func (b *RouteBuilder) Consumes(mimeTypes ...string) *RouteBuilder { … } // Path specifies the relative (w.r.t WebService root path) URL path to match. Default is "/". func (b *RouteBuilder) Path(subPath string) *RouteBuilder { … } // Doc tells what this route is all about. Optional. func (b *RouteBuilder) Doc(documentation string) *RouteBuilder { … } // Notes is a verbose explanation of the operation behavior. Optional. func (b *RouteBuilder) Notes(notes string) *RouteBuilder { … } // Reads tells what resource type will be read from the request payload. Optional. // A parameter of type "body" is added ,required is set to true and the dataType is set to the qualified name of the sample's type. func (b *RouteBuilder) Reads(sample interface{ … } // ParameterNamed returns a Parameter already known to the RouteBuilder. Returns nil if not. // Use this to modify or extend information for the Parameter (through its Data()). func (b RouteBuilder) ParameterNamed(name string) (p *Parameter) { … } // Writes tells which one of the resource types will be written as the response payload. Optional. func (b *RouteBuilder) Writes(samples ...interface{ … } // Param allows you to document the parameters of the Route. It adds a new Parameter (does not check for duplicates). func (b *RouteBuilder) Param(parameter *Parameter) *RouteBuilder { … } // Operation allows you to document what the actual method/function call is of the Route. // Unless called, the operation name is derived from the RouteFunction set using To(..). func (b *RouteBuilder) Operation(name string) *RouteBuilder { … } // ReturnsError is deprecated, use Returns instead. func (b *RouteBuilder) ReturnsError(code int, message string, model interface{ … } // Returns allows you to document what responses (errors or regular) can be expected. // The model parameter is optional ; either pass a struct instance or use nil if not applicable. func (b *RouteBuilder) Returns(code int, message string, model interface{ … } // ReturnsWithHeaders is similar to Returns, but can specify response headers func (b *RouteBuilder) ReturnsWithHeaders(code int, message string, model interface{ … } // DefaultReturns is a special Returns call that sets the default of the response. func (b *RouteBuilder) DefaultReturns(message string, model interface{ … } // Metadata adds or updates a key=value pair to the metadata map. func (b *RouteBuilder) Metadata(key string, value interface{ … } // AddExtension adds or updates a key=value pair to the extensions map. func (b *RouteBuilder) AddExtension(key string, value interface{ … } // Deprecate sets the value of deprecated to true. Deprecated routes have a special UI treatment to warn against use func (b *RouteBuilder) Deprecate() *RouteBuilder { … } // AllowedMethodsWithoutContentType overrides the default list GET,HEAD,OPTIONS,DELETE,TRACE // If a request does not include a content-type header then // depending on the method, it may return a 415 Unsupported Media. // Must have uppercase HTTP Method names such as GET,HEAD,OPTIONS,... func (b *RouteBuilder) AllowedMethodsWithoutContentType(methods []string) *RouteBuilder { … } type ResponseError … type Header … type Items … func (b *RouteBuilder) servicePath(path string) *RouteBuilder { … } // Filter appends a FilterFunction to the end of filters for this Route to build. func (b *RouteBuilder) Filter(filter FilterFunction) *RouteBuilder { … } // If sets a condition function that controls matching the Route based on custom logic. // The condition function is provided the HTTP request and should return true if the route // should be considered. // // Efficiency note: the condition function is called before checking the method, produces, and // consumes criteria, so that the correct HTTP status code can be returned. // // Lifecycle note: no filter functions have been called prior to calling the condition function, // so the condition function should not depend on any context that might be set up by container // or route filters. func (b *RouteBuilder) If(condition RouteSelectionConditionFunction) *RouteBuilder { … } // ContentEncodingEnabled allows you to override the Containers value for auto-compressing this route response. func (b *RouteBuilder) ContentEncodingEnabled(enabled bool) *RouteBuilder { … } // If no specific Route path then set to rootPath // If no specific Produces then set to rootProduces // If no specific Consumes then set to rootConsumes func (b *RouteBuilder) copyDefaults(rootProduces, rootConsumes []string) { … } // typeNameHandler sets the function that will convert types to strings in the parameter // and model definitions. func (b *RouteBuilder) typeNameHandler(handler TypeNameHandleFunction) *RouteBuilder { … } // Build creates a new Route using the specification details collected by the RouteBuilder func (b *RouteBuilder) Build() Route { … } // merge two paths using the current (package global) merge path strategy. func concatPath(rootPath, routePath string) string { … } var anonymousFuncCount … // nameOfFunction returns the short name of the function f for documentation. // It uses a runtime feature for debugging ; its value may change for later Go versions. func nameOfFunction(f interface{ … }