api

package
v0.0.0-...-a5025f8 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpOnlyCookieAuthKey = "auth-token-http-only"
	CookieAuthKey         = "auth-token"
	CookieUserKey         = "user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func New

func New(db *database.DB, config *models.Config, logger *log.Logger) *API

New declares a new API instance

func (*API) CreateProblem

func (s *API) CreateProblem(w http.ResponseWriter, r *http.Request)

CreateProblem is the handler behind POST /api/problems/

func (*API) CreateSubmission

func (s *API) CreateSubmission(w http.ResponseWriter, r *http.Request)

CreateSubmission is the handler behind POST /api/submissions/

func (*API) CreateTest

func (s *API) CreateTest(w http.ResponseWriter, r *http.Request)

CreateTest is the handler behind POST /api/tests/

func (*API) DeleteByName

func (s *API) DeleteByName(w http.ResponseWriter, r *http.Request)

CreateProblem is the handler behind DELETE /api/problems/{problemName}

func (*API) DeleteTestById

func (s *API) DeleteTestById(w http.ResponseWriter, r *http.Request)

DeleteTestById is the handler behind DELETE /api/tests/{testId}

func (*API) GetAllTests

func (s *API) GetAllTests(w http.ResponseWriter, r *http.Request)

CreateTest is the handler behind GET /api/tests/

func (*API) GetAllUsers

func (s *API) GetAllUsers(w http.ResponseWriter, r *http.Request)

GetUserByUserName is the handler behind GET /api/users/

func (*API) GetProblemByName

func (s *API) GetProblemByName(w http.ResponseWriter, r *http.Request)

GetProblemByName is the handler behind GET /api/problems/{problemName}

func (*API) GetProblemTests

func (s *API) GetProblemTests(w http.ResponseWriter, r *http.Request)

GetProblemTests is the handler behind GET /api/tests/{problemName} Returns all the tests for the specified problem

func (*API) GetProblems

func (s *API) GetProblems(w http.ResponseWriter, r *http.Request)

GetProblems is the handler behind GET /api/problems/ URL parameters could be sent for data filtering ex. GET /api/problems?authorId=1&difficulty=easy params available: authorId(int), Difficulty(string), credits(string), stream(string)

func (*API) GetSubmissionById

func (s *API) GetSubmissionById(w http.ResponseWriter, r *http.Request)

GetSubmissions is the handler behind GET /api/submissions/{submissionId}

func (*API) GetSubmissionTestById

func (s *API) GetSubmissionTestById(w http.ResponseWriter, r *http.Request)

func (*API) GetSubmissionTests

func (s *API) GetSubmissionTests(w http.ResponseWriter, r *http.Request)

GET /api/submission-tests/{submissionId}

func (*API) GetSubmissions

func (s *API) GetSubmissions(w http.ResponseWriter, r *http.Request)

GetSubmissions is the handler behind GET /api/submissions/ URL parameters could be sent for data filtering ex. GET /api/submissions?lang=go&score=100 params available: userId(int), problemId(int), score(int), lang(string), status(string), compileError(boolean)

func (*API) GetTestById

func (s *API) GetTestById(w http.ResponseWriter, r *http.Request)

GetTestById is the handler behind GET /api/tests/{testId}

func (*API) GetUserByUserName

func (s *API) GetUserByUserName(w http.ResponseWriter, r *http.Request)

GetUserByUserName is the handler behind GET /api/users/{username}

func (*API) Login

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

Login is the handler behind POST /api/auth/login.

func (*API) Logout

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

func (*API) MustBeAdmin

func (s *API) MustBeAdmin(next http.Handler) http.Handler

MustBeAdmin is a middleware that makes sure that the user creating the request is an admin.

func (*API) MustBeAuthed

func (s *API) MustBeAuthed(next http.Handler) http.Handler

MustBeAuthed is a middleware that makes sure that the user creating the request is authenticated.

func (*API) MustBeProposer

func (s *API) MustBeProposer(next http.Handler) http.Handler

MustBeProposer is a middleware that makes sure that the user creating the request is a proposer.

func (*API) MustNotBeAuthed

func (s *API) MustNotBeAuthed(next http.Handler) http.Handler

MustNotBeAuthed is a middleware that makes sure that the user creating the request is not authenticated.

func (*API) ProblemCtx

func (s *API) ProblemCtx(next http.Handler) http.Handler

ProblemCtx middleware is used to attach the problem from the URL parameters to the request context.

func (*API) Routes

func (s *API) Routes() http.Handler

Routes returns the handler that will be used for the route /api

func (*API) Signup

func (s *API) Signup(w http.ResponseWriter, r *http.Request)

Signup is the handler behind POST /api/auth/signup.

func (*API) SubmissionCtx

func (s *API) SubmissionCtx(next http.Handler) http.Handler

SubmissionCtx middleware is used to attach the file-managers from the URL parameters to the request context.

func (*API) SubmissionTestCtx

func (s *API) SubmissionTestCtx(next http.Handler) http.Handler

func (*API) TestCtx

func (s *API) TestCtx(next http.Handler) http.Handler

TestCtx middleware is used to attach the test from the URL parameters to the request context.

func (*API) UpdateProblemByName

func (s *API) UpdateProblemByName(w http.ResponseWriter, r *http.Request)

CreateProblem is the handler behind PUT /api/problems/{problemName}

func (*API) UpdateTestById

func (s *API) UpdateTestById(w http.ResponseWriter, r *http.Request)

UpdateTestById is the handler behind PUT /api/tests/

func (*API) UserCtx

func (s *API) UserCtx(next http.Handler) http.Handler

UserCtx is a middleware that attaches the user to the request context.

type UserGravatarResponse

type UserGravatarResponse struct {
	EmailHash string `json:"emailHash"`
	Username  string `json:"username"`
}

Jump to

Keyboard shortcuts

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