server

package
v0.0.0-...-163ab7f Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2017 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExitCodeOK = 0

	// Specific error codes. begin 10-
	ExitCodeError = 10 + iota
	ExitCodeParseError
	ExitCodeInvalidArgsError
)

Exit codes. used only in Run()

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, code int, err error, msg string)

Error is wrapped Respond when error response

func JSON

func JSON(w http.ResponseWriter, code int, src interface{})

JSON is wrapped Respond when success response

func Respond

func Respond(w http.ResponseWriter, code int, src interface{})

Respond is response write to ResponseWriter

Types

type CLI

type CLI struct {
	OutStream io.Writer
	ErrStream io.Writer
}

CLI is the command line interface object

func (*CLI) Run

func (c *CLI) Run(args []string) int

Run invokes the CLI with the given arguments

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"reason"`
	Error   error  `json:"-"`
}

ErrorResponse is Error response template

func (*ErrorResponse) String

func (e *ErrorResponse) String() string

type Server

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

Server supply HTTP server of the portal

func NewServer

func NewServer(pubsubAddr string) (*Server, error)

NewServer returns initialized Server

func (*Server) Enqueue

func (s *Server) Enqueue(w http.ResponseWriter, r *http.Request)

Enqueue send queue to the pubsub server

func (*Server) GetTeam

func (s *Server) GetTeam(w http.ResponseWriter, r *http.Request)

GetTeam returns login team

func (*Server) History

func (s *Server) History(w http.ResponseWriter, r *http.Request)

History returns score histories

func (*Server) Login

func (s *Server) Login(w http.ResponseWriter, r *http.Request)

Login authentication user and save user for session

func (*Server) Logout

func (s *Server) Logout(w http.ResponseWriter, r *http.Request)

Logout returns login page with cleanup session

func (*Server) Polling

func (s *Server) Polling() error

Polling call pull API from the result pubsub

func (*Server) Queues

func (s *Server) Queues(w http.ResponseWriter, r *http.Request)

Queues returns active queue list

func (*Server) Routes

func (s *Server) Routes() *router.Router

Routes returns router

func (*Server) Run

func (s *Server) Run(port int) error

Run start server

func (*Server) ScoreDetail

func (s *Server) ScoreDetail(w http.ResponseWriter, r *http.Request, id int)

ScoreDetail returns score detail

Jump to

Keyboard shortcuts

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