remotohttp

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

README

remotohttp

Remoto HTTP server.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r *http.Request, v interface{}) error

Decode extracts the incoming data from the http.Request.

func Encode

func Encode(w http.ResponseWriter, r *http.Request, status int, v interface{}) error

Encode writes the response.

func EncodeErr

func EncodeErr(w http.ResponseWriter, r *http.Request, err error) error

EncodeErr writes an error response with http.StatusInternalServerError.

Types

type Error

type Error struct {
	Err error `json:"error"`
}

Error is an error wrapper for responses.

type Server

type Server struct {

	// NotFound handles 404 responses.
	NotFound http.Handler

	// OnErr is called when there has been a system level error,
	// like encoding/decoding.
	OnErr func(w http.ResponseWriter, r *http.Request, err error)
	// contains filtered or unexported fields
}

Server is an HTTP server for serving Remoto requests.

func NewServer

func NewServer() *Server

NewServer makes a new Server.

func (*Server) Describe

func (srv *Server) Describe(w io.Writer) error

Describe an overview of the endpoints to the specified io.Writer.

func (*Server) Register

func (srv *Server) Register(path string, fn http.Handler)

Register registers the path with the http.Handler.

func (*Server) ServeHTTP

func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP calls the registered handler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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