coild

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	APIErrBadRequest     = APIError{http.StatusBadRequest, "invalid request", nil}
	APIErrForbidden      = APIError{http.StatusForbidden, "forbidden", nil}
	APIErrNotFound       = APIError{http.StatusNotFound, "requested resource is not found", nil}
	APIErrBadMethod      = APIError{http.StatusMethodNotAllowed, "method not allowed", nil}
	APIErrConflict       = APIError{http.StatusConflict, "conflicted", nil}
	APIErrLengthRequired = APIError{http.StatusLengthRequired, "content-length is required", nil}
	APIErrTooLargeAsset  = APIError{http.StatusRequestEntityTooLarge, "too large asset", nil}
)

Common API errors

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status  int
	Message string
	Err     error
}

APIError is to define REST API errors.

func BadRequest

func BadRequest(reason string) APIError

BadRequest creates an APIError that describes what was bad in the request.

func InternalServerError

func InternalServerError(e error) APIError

InternalServerError creates an APIError.

func (APIError) Error

func (e APIError) Error() string

Error implements error interface.

type Server

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

Server keeps coild internal status.

func NewServer

func NewServer(db model.Model, tableID, protocolID int) *Server

NewServer creates a new Server.

func (*Server) Init

func (s *Server) Init(ctx context.Context) error

Init loads status data from the database.

func (*Server) ServeHTTP

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

ServeHTTP implements http.Handler.

Jump to

Keyboard shortcuts

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