server

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2020 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRouteFunc added in v1.4.4

func GetRouteFunc(invoker protocol.Invoker, methodConfig *rest_config.RestMethodConfig) func(req RestServerRequest, resp RestServerResponse)

GetRouteFunc A route function will be invoked by http server

Types

type RestServer

type RestServer interface {
	// Start rest server
	Start(url common.URL)
	// Deploy a http api
	Deploy(restMethodConfig *rest_config.RestMethodConfig, routeFunc func(request RestServerRequest, response RestServerResponse))
	// UnDeploy a http api
	UnDeploy(restMethodConfig *rest_config.RestMethodConfig)
	// Destroy rest server
	Destroy()
}

RestServer user can implement this server interface

type RestServerRequest added in v1.4.4

type RestServerRequest interface {
	// RawRequest get the Ptr of http.Request
	RawRequest() *http.Request
	// PathParameter get the path parameter by name
	PathParameter(name string) string
	// PathParameters get the map of the path parameters
	PathParameters() map[string]string
	// QueryParameter get the query parameter by name
	QueryParameter(name string) string
	// QueryParameters get the map of query parameters
	QueryParameters(name string) []string
	// BodyParameter get the body parameter of name
	BodyParameter(name string) (string, error)
	// HeaderParameter get the header parameter of name
	HeaderParameter(name string) string
	// ReadEntity checks the Accept header and reads the content into the entityPointer.
	ReadEntity(entityPointer interface{}) error
}

RestServerRequest interface

type RestServerResponse added in v1.4.4

type RestServerResponse interface {
	http.ResponseWriter
	// 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(httpStatus int, err error) (writeErr error)
	// WriteEntity marshals the value using the representation denoted by the Accept Header.
	WriteEntity(value interface{}) error
}

RestServerResponse interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL