httpd

package
v0.0.0-...-5837768 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package httpd provides components to build a HTTP service.

We are using the echo HTTP framework for routing and middleware. At the top level we provide extensions to the echo framework. HTTP route handlers are defined in the subpackage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapContext

func WrapContext(h echo.HandlerFunc) echo.HandlerFunc

WrapContext wraps echo.Context as Context.

You can register this function as middleware in echo such that our extended Context type can be interferred from our handlers.

Types

type Context

type Context struct {
	echo.Context
}

Context extends echo.Context.

A context can be seen as the bigger scope in which a HTTP response and request life. We extend the default context provided by the echo framework to give us an entry point for utilities.

func (*Context) Accept

func (c *Context) Accept() []string

Accept returns the mime type the client accepts as response.

func (*Context) Accepts

func (c *Context) Accepts(mtype string) bool

Accepts returns true if the client accepts the given mime type.

By using this method we can distinguish between the data format used by different clients. For example a web application might prefer JSON formated data while a java application might prefer XML.

In case of the client accepting all mime types "*/*" this function will just return true.

func (*Context) ContentType

func (c *Context) ContentType() string

ContentType returns the normalized mime type of the request content.

Directories

Path Synopsis
Package handler provides HTTP handlers to mediate between the model and the driver package.
Package handler provides HTTP handlers to mediate between the model and the driver package.

Jump to

Keyboard shortcuts

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