code
stringlengths
12
335k
docstring
stringlengths
20
20.8k
func_name
stringlengths
1
105
language
stringclasses
1 value
repo
stringclasses
498 values
path
stringlengths
5
172
url
stringlengths
43
235
license
stringclasses
4 values
func (b *RouteBuilder) Filter(filter FilterFunction) *RouteBuilder { b.filters = append(b.filters, filter) return b }
Filter appends a FilterFunction to the end of filters for this Route to build.
Filter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/route_builder.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/route_builder.go
Apache-2.0
func (b *RouteBuilder) If(condition RouteSelectionConditionFunction) *RouteBuilder { b.conditions = append(b.conditions, condition) return b }
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.
If
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/route_builder.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/route_builder.go
Apache-2.0
func (b *RouteBuilder) ContentEncodingEnabled(enabled bool) *RouteBuilder { b.contentEncodingEnabled = &enabled return b }
ContentEncodingEnabled allows you to override the Containers value for auto-compressing this route response.
ContentEncodingEnabled
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/route_builder.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/route_builder.go
Apache-2.0
func (b *RouteBuilder) copyDefaults(rootProduces, rootConsumes []string) { if len(b.produces) == 0 { b.produces = rootProduces } if len(b.consumes) == 0 { b.consumes = rootConsumes } }
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
copyDefaults
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/route_builder.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/route_builder.go
Apache-2.0
func (b *RouteBuilder) typeNameHandler(handler TypeNameHandleFunction) *RouteBuilder { b.typeNameHandleFunc = handler return b }
typeNameHandler sets the function that will convert types to strings in the parameter and model definitions.
typeNameHandler
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/route_builder.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/route_builder.go
Apache-2.0
func (b *RouteBuilder) Build() Route { pathExpr, err := newPathExpression(b.currentPath) if err != nil { log.Printf("Invalid path:%s because:%v", b.currentPath, err) os.Exit(1) } if b.function == nil { log.Printf("No function specified for route:" + b.currentPath) os.Exit(1) } operationName := b.operation if len(operationName) == 0 && b.function != nil { // extract from definition operationName = nameOfFunction(b.function) } route := Route{ Method: b.httpMethod, Path: concatPath(b.rootPath, b.currentPath), Produces: b.produces, Consumes: b.consumes, Function: b.function, Filters: b.filters, If: b.conditions, relativePath: b.currentPath, pathExpr: pathExpr, Doc: b.doc, Notes: b.notes, Operation: operationName, ParameterDocs: b.parameters, ResponseErrors: b.errorMap, DefaultResponse: b.defaultResponse, ReadSample: b.readSample, WriteSamples: b.writeSamples, Metadata: b.metadata, Deprecated: b.deprecated, contentEncodingEnabled: b.contentEncodingEnabled, allowedMethodsWithoutContentType: b.allowedMethodsWithoutContentType, } // set WriteSample if one specified if len(b.writeSamples) == 1 { route.WriteSample = b.writeSamples[0] } route.Extensions = b.extensions route.postBuild() return route }
Build creates a new Route using the specification details collected by the RouteBuilder
Build
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/route_builder.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/route_builder.go
Apache-2.0
func concatPath(rootPath, routePath string) string { if TrimRightSlashEnabled { return strings.TrimRight(rootPath, "/") + "/" + strings.TrimLeft(routePath, "/") } else { return path.Join(rootPath, routePath) } }
merge two paths using the current (package global) merge path strategy.
concatPath
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/route_builder.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/route_builder.go
Apache-2.0
func nameOfFunction(f interface{}) string { fun := runtime.FuncForPC(reflect.ValueOf(f).Pointer()) tokenized := strings.Split(fun.Name(), ".") last := tokenized[len(tokenized)-1] last = strings.TrimSuffix(last, ")·fm") // < Go 1.5 last = strings.TrimSuffix(last, ")-fm") // Go 1.5 last = strings.TrimSuffix(last, "·fm") // < Go 1.5 last = strings.TrimSuffix(last, "-fm") // Go 1.5 if last == "func1" { // this could mean conflicts in API docs val := atomic.AddInt32(&anonymousFuncCount, 1) last = "func" + fmt.Sprintf("%d", val) atomic.StoreInt32(&anonymousFuncCount, val) } return last }
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.
nameOfFunction
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/route_builder.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/route_builder.go
Apache-2.0
func NewSyncPoolCompessors() *SyncPoolCompessors { return &SyncPoolCompessors{ GzipWriterPool: &sync.Pool{ New: func() interface{} { return newGzipWriter() }, }, GzipReaderPool: &sync.Pool{ New: func() interface{} { return newGzipReader() }, }, ZlibWriterPool: &sync.Pool{ New: func() interface{} { return newZlibWriter() }, }, } }
NewSyncPoolCompessors returns a new ("empty") SyncPoolCompessors.
NewSyncPoolCompessors
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/compressor_pools.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/compressor_pools.go
Apache-2.0
func RegisterEntityAccessor(mime string, erw EntityReaderWriter) { entityAccessRegistry.protection.Lock() defer entityAccessRegistry.protection.Unlock() entityAccessRegistry.accessors[mime] = erw }
RegisterEntityAccessor add/overrides the ReaderWriter for encoding content with this MIME type.
RegisterEntityAccessor
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
Apache-2.0
func NewEntityAccessorJSON(contentType string) EntityReaderWriter { return entityJSONAccess{ContentType: contentType} }
NewEntityAccessorJSON returns a new EntityReaderWriter for accessing JSON content. This package is already initialized with such an accessor using the MIME_JSON contentType.
NewEntityAccessorJSON
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
Apache-2.0
func NewEntityAccessorXML(contentType string) EntityReaderWriter { return entityXMLAccess{ContentType: contentType} }
NewEntityAccessorXML returns a new EntityReaderWriter for accessing XML content. This package is already initialized with such an accessor using the MIME_XML contentType.
NewEntityAccessorXML
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
Apache-2.0
func (r *entityReaderWriters) accessorAt(mime string) (EntityReaderWriter, bool) { r.protection.RLock() defer r.protection.RUnlock() er, ok := r.accessors[mime] if !ok { // retry with reverse lookup // more expensive but we are in an exceptional situation anyway for k, v := range r.accessors { if strings.Contains(mime, k) { return v, true } } } return er, ok }
accessorAt returns the registered ReaderWriter for this MIME type.
accessorAt
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
Apache-2.0
func (e entityXMLAccess) Read(req *Request, v interface{}) error { return xml.NewDecoder(req.Request.Body).Decode(v) }
Read unmarshalls the value from XML
Read
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
Apache-2.0
func (e entityXMLAccess) Write(resp *Response, status int, v interface{}) error { return writeXML(resp, status, e.ContentType, v) }
Write marshalls the value to JSON and set the Content-Type Header.
Write
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
Apache-2.0
func writeXML(resp *Response, status int, contentType string, v interface{}) error { if v == nil { resp.WriteHeader(status) // do not write a nil representation return nil } if resp.prettyPrint { // pretty output must be created and written explicitly output, err := xml.MarshalIndent(v, " ", " ") if err != nil { return err } resp.Header().Set(HEADER_ContentType, contentType) resp.WriteHeader(status) _, err = resp.Write([]byte(xml.Header)) if err != nil { return err } _, err = resp.Write(output) return err } // not-so-pretty resp.Header().Set(HEADER_ContentType, contentType) resp.WriteHeader(status) return xml.NewEncoder(resp).Encode(v) }
writeXML marshalls the value to JSON and set the Content-Type Header.
writeXML
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
Apache-2.0
func (e entityJSONAccess) Read(req *Request, v interface{}) error { decoder := NewDecoder(req.Request.Body) decoder.UseNumber() return decoder.Decode(v) }
Read unmarshalls the value from JSON
Read
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
Apache-2.0
func (e entityJSONAccess) Write(resp *Response, status int, v interface{}) error { return writeJSON(resp, status, e.ContentType, v) }
Write marshalls the value to JSON and set the Content-Type Header.
Write
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
Apache-2.0
func writeJSON(resp *Response, status int, contentType string, v interface{}) error { if v == nil { resp.WriteHeader(status) // do not write a nil representation return nil } if resp.prettyPrint { // pretty output must be created and written explicitly output, err := MarshalIndent(v, "", " ") if err != nil { return err } resp.Header().Set(HEADER_ContentType, contentType) resp.WriteHeader(status) _, err = resp.Write(output) return err } // not-so-pretty resp.Header().Set(HEADER_ContentType, contentType) resp.WriteHeader(status) return NewEncoder(resp).Encode(v) }
write marshalls the value to JSON and set the Content-Type Header.
writeJSON
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/entity_accessors.go
Apache-2.0
func NewResponse(httpWriter http.ResponseWriter) *Response { hijacker, _ := httpWriter.(http.Hijacker) return &Response{ResponseWriter: httpWriter, routeProduces: []string{}, statusCode: http.StatusOK, prettyPrint: PrettyPrintResponses, hijacker: hijacker} }
NewResponse creates a new response based on a http ResponseWriter.
NewResponse
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func DefaultResponseContentType(mime string) { DefaultResponseMimeType = mime }
DefaultResponseContentType set a default. If Accept header matching fails, fall back to this type. Valid values are restful.MIME_JSON and restful.MIME_XML Example: restful.DefaultResponseContentType(restful.MIME_JSON)
DefaultResponseContentType
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r Response) InternalServerError() Response { r.WriteHeader(http.StatusInternalServerError) return r }
InternalServerError writes the StatusInternalServerError header. DEPRECATED, use WriteErrorString(http.StatusInternalServerError,reason)
InternalServerError
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error) { if r.hijacker == nil { return nil, nil, errors.New("http.Hijacker not implemented by underlying http.ResponseWriter") } return r.hijacker.Hijack() }
Hijack implements the http.Hijacker interface. This expands the Response to fulfill http.Hijacker if the underlying http.ResponseWriter supports it.
Hijack
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) PrettyPrint(bePretty bool) { r.prettyPrint = bePretty }
PrettyPrint changes whether this response must produce pretty (line-by-line, indented) JSON or XML output.
PrettyPrint
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r Response) AddHeader(header string, value string) Response { r.Header().Add(header, value) return r }
AddHeader is a shortcut for .Header().Add(header,value)
AddHeader
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) SetRequestAccepts(mime string) { r.requestAccept = mime }
SetRequestAccepts tells the response what Mime-type(s) the HTTP request said it wants to accept. Exposed for testing.
SetRequestAccepts
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) EntityWriter() (EntityReaderWriter, bool) { sorted := sortedMimes(r.requestAccept) for _, eachAccept := range sorted { for _, eachProduce := range r.routeProduces { if eachProduce == eachAccept.media { if w, ok := entityAccessRegistry.accessorAt(eachAccept.media); ok { return w, true } } } if eachAccept.media == "*/*" { for _, each := range r.routeProduces { if w, ok := entityAccessRegistry.accessorAt(each); ok { return w, true } } } } // if requestAccept is empty writer, ok := entityAccessRegistry.accessorAt(r.requestAccept) if !ok { // if not registered then fallback to the defaults (if set) if DefaultResponseMimeType == MIME_JSON { return entityAccessRegistry.accessorAt(MIME_JSON) } if DefaultResponseMimeType == MIME_XML { return entityAccessRegistry.accessorAt(MIME_XML) } if DefaultResponseMimeType == MIME_ZIP { return entityAccessRegistry.accessorAt(MIME_ZIP) } // Fallback to whatever the route says it can produce. // https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for _, each := range r.routeProduces { if w, ok := entityAccessRegistry.accessorAt(each); ok { return w, true } } if trace { traceLogger.Printf("no registered EntityReaderWriter found for %s", r.requestAccept) } } return writer, ok }
EntityWriter returns the registered EntityWriter that the entity (requested resource) can write according to what the request wants (Accept) and what the Route can produce or what the restful defaults say. If called before WriteEntity and WriteHeader then a false return value can be used to write a 406: Not Acceptable.
EntityWriter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteEntity(value interface{}) error { return r.WriteHeaderAndEntity(http.StatusOK, value) }
WriteEntity calls WriteHeaderAndEntity with Http Status OK (200)
WriteEntity
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteHeaderAndEntity(status int, value interface{}) error { writer, ok := r.EntityWriter() if !ok { r.WriteHeader(http.StatusNotAcceptable) return nil } return writer.Write(r, status, value) }
WriteHeaderAndEntity marshals the value using the representation denoted by the Accept Header and the registered EntityWriters. If no Accept header is specified (or */*) then respond with the Content-Type as specified by the first in the Route.Produces. If an Accept header is specified then respond with the Content-Type as specified by the first in the Route.Produces that is matched with the Accept header. If the value is nil then no response is send except for the Http status. You may want to call WriteHeader(http.StatusNotFound) instead. If there is no writer available that can represent the value in the requested MIME type then Http Status NotAcceptable is written. Current implementation ignores any q-parameters in the Accept Header. Returns an error if the value could not be written on the response.
WriteHeaderAndEntity
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteAsXml(value interface{}) error { return writeXML(r, http.StatusOK, MIME_XML, value) }
WriteAsXml is a convenience method for writing a value in xml (requires Xml tags on the value) It uses the standard encoding/xml package for marshalling the value ; not using a registered EntityReaderWriter.
WriteAsXml
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteHeaderAndXml(status int, value interface{}) error { return writeXML(r, status, MIME_XML, value) }
WriteHeaderAndXml is a convenience method for writing a status and value in xml (requires Xml tags on the value) It uses the standard encoding/xml package for marshalling the value ; not using a registered EntityReaderWriter.
WriteHeaderAndXml
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteAsJson(value interface{}) error { return writeJSON(r, http.StatusOK, MIME_JSON, value) }
WriteAsJson is a convenience method for writing a value in json. It uses the standard encoding/json package for marshalling the value ; not using a registered EntityReaderWriter.
WriteAsJson
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteJson(value interface{}, contentType string) error { return writeJSON(r, http.StatusOK, contentType, value) }
WriteJson is a convenience method for writing a value in Json with a given Content-Type. It uses the standard encoding/json package for marshalling the value ; not using a registered EntityReaderWriter.
WriteJson
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteHeaderAndJson(status int, value interface{}, contentType string) error { return writeJSON(r, status, contentType, value) }
WriteHeaderAndJson is a convenience method for writing the status and a value in Json with a given Content-Type. It uses the standard encoding/json package for marshalling the value ; not using a registered EntityReaderWriter.
WriteHeaderAndJson
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteError(httpStatus int, err error) (writeErr error) { r.err = err if err == nil { writeErr = r.WriteErrorString(httpStatus, "") } else { writeErr = r.WriteErrorString(httpStatus, err.Error()) } return writeErr }
WriteError writes the http status and the error string on the response. err can be nil. Return an error if writing was not successful.
WriteError
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteServiceError(httpStatus int, err ServiceError) error { r.err = err return r.WriteHeaderAndEntity(httpStatus, err) }
WriteServiceError is a convenience method for a responding with a status and a ServiceError
WriteServiceError
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteErrorString(httpStatus int, errorReason string) error { if r.err == nil { // if not called from WriteError r.err = errors.New(errorReason) } r.WriteHeader(httpStatus) if _, err := r.Write([]byte(errorReason)); err != nil { return err } return nil }
WriteErrorString is a convenience method for an error status with the actual error
WriteErrorString
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) Flush() { if f, ok := r.ResponseWriter.(http.Flusher); ok { f.Flush() } else if trace { traceLogger.Printf("ResponseWriter %v doesn't support Flush", r) } }
Flush implements http.Flusher interface, which sends any buffered data to the client.
Flush
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) WriteHeader(httpStatus int) { r.statusCode = httpStatus r.ResponseWriter.WriteHeader(httpStatus) }
WriteHeader is overridden to remember the Status Code that has been written. Changes to the Header of the response have no effect after this.
WriteHeader
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r Response) StatusCode() int { if 0 == r.statusCode { // no status code has been written yet; assume OK return http.StatusOK } return r.statusCode }
StatusCode returns the code that has been written using WriteHeader.
StatusCode
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r *Response) Write(bytes []byte) (int, error) { written, err := r.ResponseWriter.Write(bytes) r.contentLength += written return written, err }
Write writes the data to the connection as part of an HTTP reply. Write is part of http.ResponseWriter interface.
Write
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r Response) ContentLength() int { return r.contentLength }
ContentLength returns the number of bytes written for the response content. Note that this value is only correct if all data is written through the Response using its Write* methods. Data written directly using the underlying http.ResponseWriter is not accounted for.
ContentLength
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r Response) CloseNotify() <-chan bool { return r.ResponseWriter.(http.CloseNotifier).CloseNotify() }
CloseNotify is part of http.CloseNotifier interface
CloseNotify
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func (r Response) Error() error { return r.err }
Error returns the err created by WriteError
Error
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/response.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/response.go
Apache-2.0
func insertMime(l []mime, e mime) []mime { for i, each := range l { // if current mime has lower quality then insert before if e.quality > each.quality { left := append([]mime{}, l[0:i]...) return append(append(left, e), l[i:]...) } } return append(l, e) }
insertMime adds a mime to a list and keeps it sorted by quality.
insertMime
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/mime.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/mime.go
Apache-2.0
func sortedMimes(accept string) (sorted []mime) { for _, each := range strings.Split(accept, ",") { typeAndQuality := strings.Split(strings.Trim(each, " "), ";") if len(typeAndQuality) == 1 { sorted = insertMime(sorted, mime{typeAndQuality[0], 1.0}) } else { // take factor qAndWeight := strings.Split(typeAndQuality[1], "=") if len(qAndWeight) == 2 && strings.Trim(qAndWeight[0], " ") == qFactorWeightingKey { f, err := strconv.ParseFloat(qAndWeight[1], 64) if err != nil { traceLogger.Printf("unable to parse quality in %s, %v", each, err) } else { sorted = insertMime(sorted, mime{typeAndQuality[0], f}) } } else { sorted = insertMime(sorted, mime{typeAndQuality[0], 1.0}) } } } return }
sortedMimes returns a list of mime sorted (desc) by its specified quality. e.g. text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
sortedMimes
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/mime.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/mime.go
Apache-2.0
func (r RouterJSR311) SelectRoute( webServices []*WebService, httpRequest *http.Request) (selectedService *WebService, selectedRoute *Route, err error) { // Identify the root resource class (WebService) dispatcher, finalMatch, err := r.detectDispatcher(httpRequest.URL.Path, webServices) if err != nil { return nil, nil, NewError(http.StatusNotFound, "") } // Obtain the set of candidate methods (Routes) routes := r.selectRoutes(dispatcher, finalMatch) if len(routes) == 0 { return dispatcher, nil, NewError(http.StatusNotFound, "404: Page Not Found") } // Identify the method (Route) that will handle the request route, ok := r.detectRoute(routes, httpRequest) return dispatcher, route, ok }
SelectRoute is part of the Router interface and returns the best match for the WebService and its Route for the given Request.
SelectRoute
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/jsr311.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/jsr311.go
Apache-2.0
func (r RouterJSR311) ExtractParameters(route *Route, webService *WebService, urlPath string) map[string]string { webServiceExpr := webService.pathExpr webServiceMatches := webServiceExpr.Matcher.FindStringSubmatch(urlPath) pathParameters := r.extractParams(webServiceExpr, webServiceMatches) routeExpr := route.pathExpr routeMatches := routeExpr.Matcher.FindStringSubmatch(webServiceMatches[len(webServiceMatches)-1]) routeParams := r.extractParams(routeExpr, routeMatches) for key, value := range routeParams { pathParameters[key] = value } return pathParameters }
ExtractParameters is used to obtain the path parameters from the route using the same matching engine as the JSR 311 router.
ExtractParameters
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/jsr311.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/jsr311.go
Apache-2.0
func (r RouterJSR311) detectRoute(routes []Route, httpRequest *http.Request) (*Route, error) { candidates := make([]*Route, 0, 8) for i, each := range routes { ok := true for _, fn := range each.If { if !fn(httpRequest) { ok = false break } } if ok { candidates = append(candidates, &routes[i]) } } if len(candidates) == 0 { if trace { traceLogger.Printf("no Route found (from %d) that passes conditional checks", len(routes)) } return nil, NewError(http.StatusNotFound, "404: Not Found") } // http method previous := candidates candidates = candidates[:0] for _, each := range previous { if httpRequest.Method == each.Method { candidates = append(candidates, each) } } if len(candidates) == 0 { if trace { traceLogger.Printf("no Route found (in %d routes) that matches HTTP method %s\n", len(previous), httpRequest.Method) } allowed := []string{} allowedLoop: for _, candidate := range previous { for _, method := range allowed { if method == candidate.Method { continue allowedLoop } } allowed = append(allowed, candidate.Method) } header := http.Header{"Allow": []string{strings.Join(allowed, ", ")}} return nil, NewErrorWithHeader(http.StatusMethodNotAllowed, "405: Method Not Allowed", header) } // content-type contentType := httpRequest.Header.Get(HEADER_ContentType) previous = candidates candidates = candidates[:0] for _, each := range previous { if each.matchesContentType(contentType) { candidates = append(candidates, each) } } if len(candidates) == 0 { if trace { traceLogger.Printf("no Route found (from %d) that matches HTTP Content-Type: %s\n", len(previous), contentType) } if httpRequest.ContentLength > 0 { return nil, NewError(http.StatusUnsupportedMediaType, "415: Unsupported Media Type") } } // accept previous = candidates candidates = candidates[:0] accept := httpRequest.Header.Get(HEADER_Accept) if len(accept) == 0 { accept = "*/*" } for _, each := range previous { if each.matchesAccept(accept) { candidates = append(candidates, each) } } if len(candidates) == 0 { if trace { traceLogger.Printf("no Route found (from %d) that matches HTTP Accept: %s\n", len(previous), accept) } available := []string{} for _, candidate := range previous { available = append(available, candidate.Produces...) } // if POST,PUT,PATCH without body method, length := httpRequest.Method, httpRequest.Header.Get("Content-Length") if (method == http.MethodPost || method == http.MethodPut || method == http.MethodPatch) && length == "" { return nil, NewError( http.StatusUnsupportedMediaType, fmt.Sprintf("415: Unsupported Media Type\n\nAvailable representations: %s", strings.Join(available, ", ")), ) } return nil, NewError( http.StatusNotAcceptable, fmt.Sprintf("406: Not Acceptable\n\nAvailable representations: %s", strings.Join(available, ", ")), ) } // return r.bestMatchByMedia(outputMediaOk, contentType, accept), nil return candidates[0], nil }
http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2
detectRoute
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/jsr311.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/jsr311.go
Apache-2.0
func (r RouterJSR311) bestMatchByMedia(routes []Route, contentType string, accept string) *Route { // TODO return &routes[0] }
http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 n/m > n/* > */*
bestMatchByMedia
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/jsr311.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/jsr311.go
Apache-2.0
func (r RouterJSR311) selectRoutes(dispatcher *WebService, pathRemainder string) []Route { filtered := &sortableRouteCandidates{} for _, each := range dispatcher.Routes() { pathExpr := each.pathExpr matches := pathExpr.Matcher.FindStringSubmatch(pathRemainder) if matches != nil { lastMatch := matches[len(matches)-1] if len(lastMatch) == 0 || lastMatch == "/" { // do not include if value is neither empty nor ‘/’. filtered.candidates = append(filtered.candidates, routeCandidate{each, len(matches) - 1, pathExpr.LiteralCount, pathExpr.VarCount}) } } } if len(filtered.candidates) == 0 { if trace { traceLogger.Printf("WebService on path %s has no routes that match URL path remainder:%s\n", dispatcher.rootPath, pathRemainder) } return []Route{} } sort.Sort(sort.Reverse(filtered)) // select other routes from candidates whoes expression matches rmatch matchingRoutes := []Route{filtered.candidates[0].route} for c := 1; c < len(filtered.candidates); c++ { each := filtered.candidates[c] if each.route.pathExpr.Matcher.MatchString(pathRemainder) { matchingRoutes = append(matchingRoutes, each.route) } } return matchingRoutes }
http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 (step 2)
selectRoutes
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/jsr311.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/jsr311.go
Apache-2.0
func (r RouterJSR311) detectDispatcher(requestPath string, dispatchers []*WebService) (*WebService, string, error) { filtered := &sortableDispatcherCandidates{} for _, each := range dispatchers { matches := each.pathExpr.Matcher.FindStringSubmatch(requestPath) if matches != nil { filtered.candidates = append(filtered.candidates, dispatcherCandidate{each, matches[len(matches)-1], len(matches), each.pathExpr.LiteralCount, each.pathExpr.VarCount}) } } if len(filtered.candidates) == 0 { if trace { traceLogger.Printf("no WebService was found to match URL path:%s\n", requestPath) } return nil, "", errors.New("not found") } sort.Sort(sort.Reverse(filtered)) return filtered.candidates[0].dispatcher, filtered.candidates[0].finalMatch, nil }
http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2 (step 1)
detectDispatcher
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/jsr311.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/jsr311.go
Apache-2.0
func (c CurlyRouter) SelectRoute( webServices []*WebService, httpRequest *http.Request) (selectedService *WebService, selected *Route, err error) { requestTokens := tokenizePath(httpRequest.URL.Path) detectedService := c.detectWebService(requestTokens, webServices) if detectedService == nil { if trace { traceLogger.Printf("no WebService was found to match URL path:%s\n", httpRequest.URL.Path) } return nil, nil, NewError(http.StatusNotFound, "404: Page Not Found") } candidateRoutes := c.selectRoutes(detectedService, requestTokens) if len(candidateRoutes) == 0 { if trace { traceLogger.Printf("no Route in WebService with path %s was found to match URL path:%s\n", detectedService.rootPath, httpRequest.URL.Path) } return detectedService, nil, NewError(http.StatusNotFound, "404: Page Not Found") } selectedRoute, err := c.detectRoute(candidateRoutes, httpRequest) if selectedRoute == nil { return detectedService, nil, err } return detectedService, selectedRoute, nil }
SelectRoute is part of the Router interface and returns the best match for the WebService and its Route for the given Request.
SelectRoute
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/curly.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/curly.go
Apache-2.0
func (c CurlyRouter) selectRoutes(ws *WebService, requestTokens []string) sortableCurlyRoutes { candidates := make(sortableCurlyRoutes, 0, 8) for _, each := range ws.routes { matches, paramCount, staticCount := c.matchesRouteByPathTokens(each.pathParts, requestTokens, each.hasCustomVerb) if matches { candidates.add(curlyRoute{each, paramCount, staticCount}) // TODO make sure Routes() return pointers? } } sort.Sort(candidates) return candidates }
selectRoutes return a collection of Route from a WebService that matches the path tokens from the request.
selectRoutes
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/curly.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/curly.go
Apache-2.0
func (c CurlyRouter) matchesRouteByPathTokens(routeTokens, requestTokens []string, routeHasCustomVerb bool) (matches bool, paramCount int, staticCount int) { if len(routeTokens) < len(requestTokens) { // proceed in matching only if last routeToken is wildcard count := len(routeTokens) if count == 0 || !strings.HasSuffix(routeTokens[count-1], "*}") { return false, 0, 0 } // proceed } for i, routeToken := range routeTokens { if i == len(requestTokens) { // reached end of request path return false, 0, 0 } requestToken := requestTokens[i] if routeHasCustomVerb && hasCustomVerb(routeToken){ if !isMatchCustomVerb(routeToken, requestToken) { return false, 0, 0 } staticCount++ requestToken = removeCustomVerb(requestToken) routeToken = removeCustomVerb(routeToken) } if strings.HasPrefix(routeToken, "{") { paramCount++ if colon := strings.Index(routeToken, ":"); colon != -1 { // match by regex matchesToken, matchesRemainder := c.regularMatchesPathToken(routeToken, colon, requestToken) if !matchesToken { return false, 0, 0 } if matchesRemainder { break } } } else { // no { prefix if requestToken != routeToken { return false, 0, 0 } staticCount++ } } return true, paramCount, staticCount }
matchesRouteByPathTokens computes whether it matches, howmany parameters do match and what the number of static path elements are.
matchesRouteByPathTokens
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/curly.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/curly.go
Apache-2.0
func (c CurlyRouter) regularMatchesPathToken(routeToken string, colon int, requestToken string) (matchesToken bool, matchesRemainder bool) { regPart := routeToken[colon+1 : len(routeToken)-1] if regPart == "*" { if trace { traceLogger.Printf("wildcard parameter detected in route token %s that matches %s\n", routeToken, requestToken) } return true, true } matched, err := regexp.MatchString(regPart, requestToken) return (matched && err == nil), false }
regularMatchesPathToken tests whether the regular expression part of routeToken matches the requestToken or all remaining tokens format routeToken is {someVar:someExpression}, e.g. {zipcode:[\d][\d][\d][\d][A-Z][A-Z]}
regularMatchesPathToken
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/curly.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/curly.go
Apache-2.0
func (c CurlyRouter) detectRoute(candidateRoutes sortableCurlyRoutes, httpRequest *http.Request) (*Route, error) { // tracing is done inside detectRoute return jsr311Router.detectRoute(candidateRoutes.routes(), httpRequest) }
detectRoute selectes from a list of Route the first match by inspecting both the Accept and Content-Type headers of the Request. See also RouterJSR311 in jsr311.go
detectRoute
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/curly.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/curly.go
Apache-2.0
func (c CurlyRouter) detectWebService(requestTokens []string, webServices []*WebService) *WebService { var best *WebService score := -1 for _, each := range webServices { matches, eachScore := c.computeWebserviceScore(requestTokens, each.pathExpr.tokens) if matches && (eachScore > score) { best = each score = eachScore } } return best }
detectWebService returns the best matching webService given the list of path tokens. see also computeWebserviceScore
detectWebService
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/curly.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/curly.go
Apache-2.0
func (c CurlyRouter) computeWebserviceScore(requestTokens []string, tokens []string) (bool, int) { if len(tokens) > len(requestTokens) { return false, 0 } score := 0 for i := 0; i < len(tokens); i++ { each := requestTokens[i] other := tokens[i] if len(each) == 0 && len(other) == 0 { score++ continue } if len(other) > 0 && strings.HasPrefix(other, "{") { // no empty match if len(each) == 0 { return false, score } score += 1 } else { // not a parameter if each != other { return false, score } score += (len(tokens) - i) * 10 //fuzzy } } return true, score }
computeWebserviceScore returns whether tokens match and the weighted score of the longest matching consecutive tokens from the beginning.
computeWebserviceScore
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/curly.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/curly.go
Apache-2.0
func (w *WebService) TypeNameHandler(handler TypeNameHandleFunction) *WebService { w.typeNameHandleFunc = handler return w }
TypeNameHandler sets the function that will convert types to strings in the parameter and model definitions. If not set, the web service will invoke reflect.TypeOf(object).String().
TypeNameHandler
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func reflectTypeName(sample interface{}) string { return reflect.TypeOf(sample).String() }
reflectTypeName is the default TypeNameHandleFunction and for a given object returns the name that Go identifies it with (e.g. "string" or "v1.Object") via the reflection API.
reflectTypeName
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) compilePathExpression() { compiled, err := newPathExpression(w.rootPath) if err != nil { log.Printf("invalid path:%s because:%v", w.rootPath, err) os.Exit(1) } w.pathExpr = compiled }
compilePathExpression ensures that the path is compiled into a RegEx for those routers that need it.
compilePathExpression
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) ApiVersion(apiVersion string) *WebService { w.apiVersion = apiVersion return w }
ApiVersion sets the API version for documentation purposes.
ApiVersion
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Version() string { return w.apiVersion }
Version returns the API version for documentation purposes.
Version
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Path(root string) *WebService { w.rootPath = root if len(w.rootPath) == 0 { w.rootPath = "/" } w.compilePathExpression() return w }
Path specifies the root URL template path of the WebService. All Routes will be relative to this path.
Path
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Param(parameter *Parameter) *WebService { if w.pathParameters == nil { w.pathParameters = []*Parameter{} } w.pathParameters = append(w.pathParameters, parameter) return w }
Param adds a PathParameter to document parameters used in the root path.
Param
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) PathParameter(name, description string) *Parameter { return PathParameter(name, description) }
PathParameter creates a new Parameter of kind Path for documentation purposes. It is initialized as required with string as its DataType.
PathParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func PathParameter(name, description string) *Parameter { p := &Parameter{&ParameterData{Name: name, Description: description, Required: true, DataType: "string"}} p.bePath() return p }
PathParameter creates a new Parameter of kind Path for documentation purposes. It is initialized as required with string as its DataType.
PathParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) QueryParameter(name, description string) *Parameter { return QueryParameter(name, description) }
QueryParameter creates a new Parameter of kind Query for documentation purposes. It is initialized as not required with string as its DataType.
QueryParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func QueryParameter(name, description string) *Parameter { p := &Parameter{&ParameterData{Name: name, Description: description, Required: false, DataType: "string", CollectionFormat: CollectionFormatCSV.String()}} p.beQuery() return p }
QueryParameter creates a new Parameter of kind Query for documentation purposes. It is initialized as not required with string as its DataType.
QueryParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) BodyParameter(name, description string) *Parameter { return BodyParameter(name, description) }
BodyParameter creates a new Parameter of kind Body for documentation purposes. It is initialized as required without a DataType.
BodyParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func BodyParameter(name, description string) *Parameter { p := &Parameter{&ParameterData{Name: name, Description: description, Required: true}} p.beBody() return p }
BodyParameter creates a new Parameter of kind Body for documentation purposes. It is initialized as required without a DataType.
BodyParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) HeaderParameter(name, description string) *Parameter { return HeaderParameter(name, description) }
HeaderParameter creates a new Parameter of kind (Http) Header for documentation purposes. It is initialized as not required with string as its DataType.
HeaderParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func HeaderParameter(name, description string) *Parameter { p := &Parameter{&ParameterData{Name: name, Description: description, Required: false, DataType: "string"}} p.beHeader() return p }
HeaderParameter creates a new Parameter of kind (Http) Header for documentation purposes. It is initialized as not required with string as its DataType.
HeaderParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) FormParameter(name, description string) *Parameter { return FormParameter(name, description) }
FormParameter creates a new Parameter of kind Form (using application/x-www-form-urlencoded) for documentation purposes. It is initialized as required with string as its DataType.
FormParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func FormParameter(name, description string) *Parameter { p := &Parameter{&ParameterData{Name: name, Description: description, Required: false, DataType: "string"}} p.beForm() return p }
FormParameter creates a new Parameter of kind Form (using application/x-www-form-urlencoded) for documentation purposes. It is initialized as required with string as its DataType.
FormParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) MultiPartFormParameter(name, description string) *Parameter { return MultiPartFormParameter(name, description) }
MultiPartFormParameter creates a new Parameter of kind Form (using multipart/form-data) for documentation purposes. It is initialized as required with string as its DataType.
MultiPartFormParameter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Route(builder *RouteBuilder) *WebService { w.routesLock.Lock() defer w.routesLock.Unlock() builder.copyDefaults(w.produces, w.consumes) w.routes = append(w.routes, builder.Build()) return w }
Route creates a new Route using the RouteBuilder and add to the ordered list of Routes.
Route
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) RemoveRoute(path, method string) error { if !w.dynamicRoutes { return errors.New("dynamic routes are not enabled.") } w.routesLock.Lock() defer w.routesLock.Unlock() newRoutes := []Route{} for _, route := range w.routes { if route.Method == method && route.Path == path { continue } newRoutes = append(newRoutes, route) } w.routes = newRoutes return nil }
RemoveRoute removes the specified route, looks for something that matches 'path' and 'method'
RemoveRoute
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Method(httpMethod string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method(httpMethod) }
Method creates a new RouteBuilder and initialize its http method
Method
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Produces(contentTypes ...string) *WebService { w.produces = contentTypes return w }
Produces specifies that this WebService can produce one or more MIME types. Http requests must have one of these values set for the Accept header.
Produces
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Consumes(accepts ...string) *WebService { w.consumes = accepts return w }
Consumes specifies that this WebService can consume one or more MIME types. Http requests must have one of these values set for the Content-Type header.
Consumes
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Routes() []Route { if !w.dynamicRoutes { return w.routes } // Make a copy of the array to prevent concurrency problems w.routesLock.RLock() defer w.routesLock.RUnlock() result := make([]Route, len(w.routes)) for ix := range w.routes { result[ix] = w.routes[ix] } return result }
Routes returns the Routes associated with this WebService
Routes
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) RootPath() string { return w.rootPath }
RootPath returns the RootPath associated with this WebService. Default "/"
RootPath
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) PathParameters() []*Parameter { return w.pathParameters }
PathParameters return the path parameter names for (shared among its Routes)
PathParameters
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Filter(filter FilterFunction) *WebService { w.filters = append(w.filters, filter) return w }
Filter adds a filter function to the chain of filters applicable to all its Routes
Filter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Doc(plainText string) *WebService { w.documentation = plainText return w }
Doc is used to set the documentation of this service.
Doc
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) Documentation() string { return w.documentation }
Documentation returns it.
Documentation
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) HEAD(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("HEAD").Path(subPath) }
HEAD is a shortcut for .Method("HEAD").Path(subPath)
HEAD
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) GET(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("GET").Path(subPath) }
GET is a shortcut for .Method("GET").Path(subPath)
GET
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) POST(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("POST").Path(subPath) }
POST is a shortcut for .Method("POST").Path(subPath)
POST
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) PUT(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("PUT").Path(subPath) }
PUT is a shortcut for .Method("PUT").Path(subPath)
PUT
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) PATCH(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("PATCH").Path(subPath) }
PATCH is a shortcut for .Method("PATCH").Path(subPath)
PATCH
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) DELETE(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("DELETE").Path(subPath) }
DELETE is a shortcut for .Method("DELETE").Path(subPath)
DELETE
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (w *WebService) OPTIONS(subPath string) *RouteBuilder { return new(RouteBuilder).typeNameHandler(w.typeNameHandleFunc).servicePath(w.rootPath).Method("OPTIONS").Path(subPath) }
OPTIONS is a shortcut for .Method("OPTIONS").Path(subPath)
OPTIONS
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/web_service.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/web_service.go
Apache-2.0
func (f *FilterChain) ProcessFilter(request *Request, response *Response) { if f.Index < len(f.Filters) { f.Index++ f.Filters[f.Index-1](request, response, f) } else { f.Target(request, response) } }
ProcessFilter passes the request,response pair through the next of Filters. Each filter can decide to proceed to the next Filter or handle the Response itself.
ProcessFilter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/filter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/filter.go
Apache-2.0
func NoBrowserCacheFilter(req *Request, resp *Response, chain *FilterChain) { resp.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") // HTTP 1.1. resp.Header().Set("Pragma", "no-cache") // HTTP 1.0. resp.Header().Set("Expires", "0") // Proxies. chain.ProcessFilter(req, resp) }
NoBrowserCacheFilter is a filter function to set HTTP headers that disable browser caching See examples/restful-no-cache-filter.go for usage
NoBrowserCacheFilter
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/filter.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/filter.go
Apache-2.0
func SetLogger(customLogger StdLogger) { Logger = customLogger }
SetLogger sets the logger for this package
SetLogger
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/log/log.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/log/log.go
Apache-2.0
func Print(v ...interface{}) { Logger.Print(v...) }
Print delegates to the Logger
Print
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/log/log.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/log/log.go
Apache-2.0
func Printf(format string, v ...interface{}) { Logger.Printf(format, v...) }
Printf delegates to the Logger
Printf
go
k8snetworkplumbingwg/multus-cni
vendor/github.com/emicklei/go-restful/v3/log/log.go
https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/vendor/github.com/emicklei/go-restful/v3/log/log.go
Apache-2.0