Documentation ¶
Overview ¶
Package web contains all the components necessary for HTTP communication
Index ¶
- Variables
- func EncodeJSONResponse(i interface{}, status int, w http.ResponseWriter) error
- func Logger(inner http.Handler, name string) http.Handler
- func NewRouter(routers ...Router) *mux.Router
- type ConnectAPIController
- type ConnectAPIRouter
- type ConnectAPIService
- type ConnectAPIServicer
- type PlayAPIController
- type PlayAPIRouter
- type PlayAPIService
- type PlayAPIServicer
- type Route
- type Router
- type Routes
Constants ¶
This section is empty.
Variables ¶
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
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