web

package
v0.0.0-...-4797095 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package web contains all the components necessary for HTTP communication

Index

Constants

This section is empty.

Variables

View Source
var Upgrader = websocket.Upgrader{}

Functions

func EncodeJSONResponse

func EncodeJSONResponse(i interface{}, status int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func Logger

func Logger(inner http.Handler, name string) http.Handler

Logger is a middleware that adds logging to every http request

func NewRouter

func NewRouter(routers ...Router) *mux.Router

NewRouter creates a new router for any number of api routers

Types

type ConnectAPIController

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

A ConnectAPIController binds http requests to an api service and writes the service results to the http response

func (*ConnectAPIController) HelloPost

func (c *ConnectAPIController) HelloPost(w http.ResponseWriter, r *http.Request)

HelloPost -

func (*ConnectAPIController) Routes

func (c *ConnectAPIController) Routes() Routes

Routes returns all of the api route for the ConnectAPIController

func (*ConnectAPIController) SwitchToWs

func (c *ConnectAPIController) SwitchToWs(w http.ResponseWriter, r *http.Request)

type ConnectAPIRouter

type ConnectAPIRouter interface {
	HelloPost(http.ResponseWriter, *http.Request)
	SwitchToWs(http.ResponseWriter, *http.Request)
}

ConnectAPIRouter is the router for the connect API

type ConnectAPIService

type ConnectAPIService struct {
}

ConnectAPIService is a service that implements the logic for the ConnectAPIServicer This service should implement the business logic for every endpoint for the ConnectApi API. Include any external packages or services that will be required by this service.

func (*ConnectAPIService) HelloPost

func (s *ConnectAPIService) HelloPost(helloRequest model.HelloRequest) (model.HelloResponse, error)

HelloPost -

func (*ConnectAPIService) SwitchToWs

func (s *ConnectAPIService) SwitchToWs(request model.SwitchToWsRequest, conn *websocket.Conn) error

type ConnectAPIServicer

type ConnectAPIServicer interface {
	HelloPost(model.HelloRequest) (model.HelloResponse, error)
	SwitchToWs(model.SwitchToWsRequest, *websocket.Conn) error
}

ConnectAPIServicer resolves the requests to the connect API

func NewConnectAPIService

func NewConnectAPIService() ConnectAPIServicer

NewConnectAPIService creates a default api service

type PlayAPIController

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

A PlayAPIController binds http requests to an api service and writes the service results to the http response

func (*PlayAPIController) PlayPost

func (c *PlayAPIController) PlayPost(w http.ResponseWriter, r *http.Request)

PlayPost -

func (*PlayAPIController) Routes

func (c *PlayAPIController) Routes() Routes

Routes returns all of the api route for the PlayAPIController

type PlayAPIRouter

type PlayAPIRouter interface {
	PlayPost(http.ResponseWriter, *http.Request)
}

PlayAPIRouter is the router for the play API

type PlayAPIService

type PlayAPIService struct {
}

PlayAPIService is a service that implents the logic for the PlayAPIServicer This service should implement the business logic for every endpoint for the PlayApi API. Include any external packages or services that will be required by this service.

func (*PlayAPIService) PlayPost

func (s *PlayAPIService) PlayPost(playRequest model.PlayRequest) (model.PlayResponse, error)

PlayPost -

type PlayAPIServicer

type PlayAPIServicer interface {
	PlayPost(model.PlayRequest) (model.PlayResponse, error)
}

PlayAPIServicer resolves the requests to the play API

func NewPlayAPIService

func NewPlayAPIService() PlayAPIServicer

NewPlayAPIService creates a default api service

type Route

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

A Route defines the parameters for an api endpoint

type Router

type Router interface {
	Routes() Routes
}

Router defines the required methods for retrieving api routes

func NewConnectAPIController

func NewConnectAPIController(s ConnectAPIServicer) Router

NewConnectAPIController creates a default api controller

func NewPlayAPIController

func NewPlayAPIController(s PlayAPIServicer) Router

NewPlayAPIController creates a default api controller

type Routes

type Routes []Route

Routes are a collection of defined api endpoints

Directories

Path Synopsis
Package model contains the data for web communication
Package model contains the data for web communication

Jump to

Keyboard shortcuts

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