Categorygithub.com/phogolabs/rest
modulepackage
0.0.0-20230307133214-552cc5bb9650
Repository: https://github.com/phogolabs/rest.git
Documentation: pkg.go.dev

# README

rest

Documentation License Build Status Coverage Go Report Card

Built Restful Services

rest

Overview

rest is a package that facilitates developing Web API Services with chi. It provides set of utility functions for sending responses and handling errors.

Installation

$ go get -u github.com/phogolabs/rest

Contributing

We are welcome to any contributions. Just fork the project.

logo made by Free Pik

# Packages

No description provided by the author

# Functions

Bind decodes a request body and executes the Binder method of the payload structure.
Data writes raw bytes to the response, setting the Content-Type as application/octet-stream.
Decode is a package-level variable set to our default Decoder.
DecodeForm decodes an entity from form fields.
DecodeHeader decodes an entity from query.
DecodePath decodes an entity from path.
DecodePath decodes an entity from path.
DecodeQuery decodes an entity from query.
EncodeHeader encodes a header.
Error injects the error within the request Deprecated: Use Respond instead.
ErrorJSON injects the error within the request Deprecated: Use JSON instead.
ErrorXML injects the error within the request Deprecated: Use XML instead.
GetLogger returns the associated request logger.
HTML writes a string to the response, setting the Content-Type as text/html.
JSON marshals 'v' to JSON, automatically escaping HTML and setting the Content-Type as application/json.
NoContent returns a HTTP 204 "No Content" response.
PlainText writes a string to the response, setting the Content-Type as text/plain.
Print prints the routes.
RegisterValidation adds a validation with the given tag.
Render renders a single payload and respond to the client request.
Respond handles streaming JSON and XML responses, automatically setting the Content-Type based on request headers.
Status sets a HTTP response status code hint into request context at any point during the request life-cycle.
UnmarshalForm unmashals form.
Validate validates a data.
XML marshals 'v' to JSON, setting the Content-Type as application/xml.

# Variables

ErrNoRouteContextFound returns no route context error.

# Interfaces

Binder interface for managing request payloads.
Renderer interface for managing response payloads.