web

package
v0.0.0-...-ca65d48 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2018 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package web interacts with frontend.

Index

Constants

View Source
const (

	// RequestIDHeader is the field name for request ID header.
	RequestIDHeader = "Request-Id"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextAdapter

type ContextAdapter struct {
	// contains filtered or unexported fields
}

ContextAdapter wraps context handler.

func (*ContextAdapter) ServeHTTP

func (ca *ContextAdapter) ServeHTTP(w http.ResponseWriter, req *http.Request)

type ContextHandler

type ContextHandler interface {
	ServeHTTPContext(context.Context, http.ResponseWriter, *http.Request) error
}

ContextHandler handles ServeHTTP with context.

type ContextHandlerFunc

type ContextHandlerFunc func(context.Context, http.ResponseWriter, *http.Request) error

ContextHandlerFunc defines HandlerFunc function signature to wrap context.

func (ContextHandlerFunc) ServeHTTPContext

func (f ContextHandlerFunc) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, req *http.Request) error

ServeHTTPContext serve HTTP requests with context.

type Request

type Request struct {
	DataFromFrontend string `json:"data_from_frontend"`
	CreateRequest    bool   `json:"create_request"`
}

Request defines requests from frontend.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server warps http.Server.

func StartServer

func StartServer(scheme, hostPort string, qu queue.Queue) (*Server, error)

StartServer starts a backend webserver with stoppable listener.

func (*Server) Stop

func (srv *Server) Stop() error

Stop stops the server. Useful for testing.

func (*Server) StopNotify

func (srv *Server) StopNotify() <-chan struct{}

StopNotify returns receive-only stop channel to notify the server has stopped.

Jump to

Keyboard shortcuts

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