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
Click to show internal directories.
Click to hide internal directories.