rest

package
v0.0.0-...-c99e1c3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"rest-server",
	fx.Provide(NewServer),
	fx.Invoke(serverLC),
)

Functions

This section is empty.

Types

type Server

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

Server represents the REST server that handles external requests (e.g. from browsers).

func NewServer

func NewServer(
	cfg config.ServerConfig,
	db *sql.DB,
	answerService *answer.Service,
	questionService *question.Service,
	meter otel.Meter,
) *Server

func (*Server) GetAnswersLog

func (s *Server) GetAnswersLog(
	w http.ResponseWriter,
	r *http.Request,
	userID uuid.UUID,
	params oapi.GetAnswersLogParams,
)

GetAnswersLog returns a list of previous attempts at answering questions from the specified user.

func (*Server) GetNextQuestion

func (s *Server) GetNextQuestion(
	w http.ResponseWriter,
	r *http.Request,
	params oapi.GetNextQuestionParams,
)

GetNextQuestion returns the next question that a user should answer for the specified topic.

func (*Server) GetRemainingTopics

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

GetRemainingTopics returns the list of topics with questions still unanswered by the user making the request. Each of these topics comes with the actual amount of questions left to answer.

func (*Server) HealthCheck

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

HealthCheck returns a 204 status code if the server is healthy, and a 503 status code otherwise.

func (*Server) Shutdown

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

func (*Server) Start

func (s *Server) Start() error

func (*Server) SubmitAnswer

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

SubmitAnswer registers the choice made by a user for a specific question, and returns the correct choice for it, plus some more info for the user to know how they did.

Directories

Path Synopsis
Package oapi provides primitives to interact with the openapi HTTP API.
Package oapi provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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