utils

package
v0.0.0-...-48f5382 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound        = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}
	ErrBadRequest      = &ErrResponse{HTTPStatusCode: 400, StatusText: "Bad request"}
	ErrInternalServer  = &ErrResponse{HTTPStatusCode: 500, StatusText: "Internal Server Error"}
	ErrUnauthorized    = &ErrResponse{HTTPStatusCode: 401, StatusText: "Unauthorized"}
	ErrForbidden       = &ErrResponse{HTTPStatusCode: 403, StatusText: "Forbidden"}
	ErrInvalidFacility = &ErrResponse{HTTPStatusCode: 400, StatusText: "Invalid facility"}
	ErrInvalidRole     = &ErrResponse{HTTPStatusCode: 400, StatusText: "Invalid role"}
	ErrInvalidCID      = &ErrResponse{HTTPStatusCode: 400, StatusText: "Invalid CID"}
)

Functions

func CanAddRole

func CanAddRole(user *models.User, roleId constants.RoleID, facilityId constants.FacilityID) bool

func CanEditFacility

func CanEditFacility(user *models.User, facility constants.FacilityID) bool

func ErrConflict

func ErrConflict(err error) render.Renderer

func ErrInternalServerWithErr

func ErrInternalServerWithErr(err error) render.Renderer

func ErrInvalidRequest

func ErrInvalidRequest(err error) render.Renderer

func ErrRender

func ErrRender(err error) render.Renderer

func GetActionLogCtx

func GetActionLogCtx(r *http.Request) *models.ActionLogEntry

func GetDisciplinaryLogCtx

func GetDisciplinaryLogCtx(r *http.Request) *models.DisciplinaryLogEntry

func GetDocumentCtx

func GetDocumentCtx(r *http.Request) *models.Document

func GetEventCtx

func GetEventCtx(r *http.Request) *models.Event

func GetEventPositionCtx

func GetEventPositionCtx(r *http.Request) *models.EventPosition

func GetEventRoutingCtx

func GetEventRoutingCtx(r *http.Request) *models.EventRouting

func GetEventSignupCtx

func GetEventSignupCtx(r *http.Request) *models.EventSignup

func GetEventTemplateCtx

func GetEventTemplateCtx(r *http.Request) *models.EventTemplate

func GetFAQCtx

func GetFAQCtx(r *http.Request) *models.FAQ

func GetFacilityCtx

func GetFacilityCtx(r *http.Request) *models.Facility

func GetFacilityLogCtx

func GetFacilityLogCtx(r *http.Request) *models.FacilityLogEntry

func GetFeedbackCtx

func GetFeedbackCtx(r *http.Request) *models.Feedback

func GetNewsCtx

func GetNewsCtx(r *http.Request) *models.News

func GetNotificationCtx

func GetNotificationCtx(r *http.Request) *models.Notification

func GetRatingChangeCtx

func GetRatingChangeCtx(r *http.Request) *models.RatingChange

func GetRosterCtx

func GetRosterCtx(r *http.Request) *models.Roster

func GetRosterRequestCtx

func GetRosterRequestCtx(r *http.Request) *models.RosterRequest

func GetUserCtx

func GetUserCtx(r *http.Request) *models.User

func GetUserFlagCtx

func GetUserFlagCtx(r *http.Request) *models.UserFlag

func GetUserNotificationCtx

func GetUserNotificationCtx(r *http.Request) *models.UserNotification

func GetUserRoleCtx

func GetUserRoleCtx(r *http.Request) *models.UserRole

func GetXFacility

func GetXFacility(r *http.Request) *models.Facility

func GetXGuest

func GetXGuest(r *http.Request) bool

func GetXUser

func GetXUser(r *http.Request) *models.User

func IsFacilityEventsStaff

func IsFacilityEventsStaff(user *models.User, facility constants.FacilityID) bool

func IsFacilitySeniorStaff

func IsFacilitySeniorStaff(user *models.User, facility constants.FacilityID) bool

func IsFacilityStaff

func IsFacilityStaff(user *models.User, facility constants.FacilityID) bool

func IsInstructor

func IsInstructor(user *models.User, facility constants.FacilityID) bool

func IsSeniorStaff

func IsSeniorStaff(user *models.User) bool

func IsVATUSAStaff

func IsVATUSAStaff(user *models.User) bool

func JSON

func JSON(w http.ResponseWriter, r *http.Request, code int, data interface{})

func Pprint

func Pprint(obj interface{})

func Render

func Render(w http.ResponseWriter, r *http.Request, renderer render.Renderer)

func Response

func Response(r *http.Request, code int)

func TempRedirect

func TempRedirect(w http.ResponseWriter, r *http.Request, location string)

Types

type AleKey

type AleKey struct{}

type DleKey

type DleKey struct{}

type DocumentKey

type DocumentKey struct{}

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"status"`          // user-level status message
	AppCode    int64  `json:"code,omitempty"`  // application-specific error code
	ErrorText  string `json:"error,omitempty"` // application-level error message, for debugging
}

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

type EventKey

type EventKey struct{}

type EventPositionKey

type EventPositionKey struct{}

type EventRoutingKey

type EventRoutingKey struct{}

type EventSignupKey

type EventSignupKey struct{}

type EventTemplateKey

type EventTemplateKey struct{}

type FAQKey

type FAQKey struct{}

type FacilityKey

type FacilityKey struct{}

type FacilityLogKey

type FacilityLogKey struct{}

type FeedbackKey

type FeedbackKey struct{}

type NewsKey

type NewsKey struct{}

type NotificationKey

type NotificationKey struct{}

type RatingChangeKey

type RatingChangeKey struct{}

type RosterKey

type RosterKey struct{}

type RosterRequestKey

type RosterRequestKey struct{}

type UserFlagKey

type UserFlagKey struct{}

type UserKey

type UserKey struct{}

type UserNotificationKey

type UserNotificationKey struct{}

type UserRoleKey

type UserRoleKey struct{}

type XFacility

type XFacility struct{}

type XGuest

type XGuest struct{}

type XUser

type XUser struct{}

Jump to

Keyboard shortcuts

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