mux

package
v4.10.4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssureContentType

func AssureContentType(w http.ResponseWriter, r *http.Request, ct string) bool

AssureContentType returns true if the requested content-type is present in the request header and returns a JSON encoded models.Error on the http stream and false value if it is not.

func AssureDecode

func AssureDecode(w http.ResponseWriter, r *http.Request, val interface{}) bool

AssureDecode returns true if can successfully decode the incoming JSON object into the provided interface. It will return false and generate a JSON encoded error message upon failure.

func Delete

func Delete(client *http.Client, path string) error

Delete provides a path for the Plugin to delete data from DRP over the Plugin Server RestFUL API.

func Get

func Get(client *http.Client, path string) ([]byte, error)

Get provides a path for the Plugin to get data from DRP over the Plugin Server RestFUL API.

func JsonResponse

func JsonResponse(w http.ResponseWriter, code int, obj interface{}) error

JsonResponse returns a JSON object on the http writer. Setting the code and encoding the provided object.

func Post

func Post(client *http.Client, path string, indata interface{}) ([]byte, error)

Post provides a path for the Plugin to send messages to DRP over the Plugin Server RestFUL API.

func TestContentType

func TestContentType(r *http.Request, ct string) (string, bool)

TestContentType tests to ensure that requested content type is in the header.

Types

type Mux

type Mux struct {
	logger.Logger
	*http.ServeMux
}

Mux provides a logger wrapper http.ServeMux to provide integration with the logger system.

func New

func New(bl logger.Logger) *Mux

New creates a new Mux structure with the provided logger.

func (*Mux) Handle

func (m *Mux) Handle(path string, h http.HandlerFunc)

Handle registers a handler at the path on the provided Mux.

type ResponseWriter

type ResponseWriter struct {
	http.ResponseWriter
	logger.Logger
	// contains filtered or unexported fields
}

ResponseWriter wraps a normal http.ResponseWriter with a logger and a status value.

func (*ResponseWriter) Status

func (rw *ResponseWriter) Status() int

Status returns the current status ofthe ResponseWriter.

func (*ResponseWriter) Write

func (rw *ResponseWriter) Write(buf []byte) (int, error)

Write sends the specified buf after setting StatusOK if no other status has been written.

func (*ResponseWriter) WriteHeader

func (rw *ResponseWriter) WriteHeader(s int)

WriteHeader takes the status code and writes the header out the http stream after recording the status.

Jump to

Keyboard shortcuts

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