http

package
v0.0.0-...-042b26a Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequestResponse

func BadRequestResponse(w http.ResponseWriter, error string)

func ErrorResponse

func ErrorResponse(w http.ResponseWriter, error string, code int)

ErrorResponse responds with and logs the given error message to the console, alongside the given response code. Any error messages will be rendered inside the #error element of the page.

func MethodNotAllowedResponse

func MethodNotAllowedResponse(w http.ResponseWriter, error string)

func NotFoundResponse

func NotFoundResponse(w http.ResponseWriter, error string)

func ServerErrorResponse

func ServerErrorResponse(w http.ResponseWriter, error string)

func UnprocessableEntityResponse

func UnprocessableEntityResponse(w http.ResponseWriter, error string)

Types

type Server

type Server struct {

	// Addr is the address for the Server to listen on.
	Addr string

	// Templates holds all the templates used by the application.
	Templates map[string]*template.Template

	// Services used by the various HTTP routes.
	EntrantService    tournament.EntrantService
	PlayerService     tournament.PlayerService
	TierService       tournament.TierService
	TournamentService tournament.TournamentService
	// contains filtered or unexported fields
}

Server provides several HTTP handlers for servicing tournament-related requests.

func NewServer

func NewServer(challongeUsername, challongePassword, startggKey string) *Server

NewServer creates a Server with the given credentials. The other fields should be applied manually.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

func (*Server) Render

func (s *Server) Render(w http.ResponseWriter, status int, tmpl, name string, data any)

Render will execute the "name" template of "tmpl", then write it to the response with the given status code.

Jump to

Keyboard shortcuts

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