Documentation ¶
Index ¶
- Variables
- func IsAdmin(token *auth.Token) bool
- func Token(ctx context.Context) *auth.Token
- func WithToken(ctx context.Context, token *auth.Token) context.Context
- type Affiliate
- type Authorizer
- type Base
- type Config
- type ErrorResponse
- func NewBadRequestError(err error) ErrorResponse
- func NewForbiddenError(err error) ErrorResponse
- func NewInternalServerError(err error) ErrorResponse
- func NewNotFoundError(err error) ErrorResponse
- func NewTooManyRequestsError(err error) ErrorResponse
- func NewUnauthorizedError(err error) ErrorResponse
- type HTMLResponseAdmin
- type HTMLResponseHuman
- type HTMLResponseHumans
- type HTMLResponseLogin
- type Handler
- type HttpHandler
- type Human
- type HumanCreateRequest
- type HumanCreateResponse
- type HumanFormFields
- type NoOpAuthorizer
- func (n NoOpAuthorizer) SessionCookie(ctx context.Context, idToken string, expiresIn time.Duration) (string, error)
- func (n NoOpAuthorizer) VerifyIDToken(ctx context.Context, idToken string) (*auth.Token, error)
- func (n NoOpAuthorizer) VerifySessionCookieAndCheckRevoked(ctx context.Context, idToken string) (*auth.Token, error)
- type ReactionResponse
- type RecentlyViewed
- type Saved
- type Server
- func (s *Server) AdminMiddleware(next http.Handler) http.Handler
- func (s *Server) AuthMiddleware(next http.Handler) http.Handler
- func (s *Server) DeleteReaction(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) GetHumanFromCache(ctx context.Context, humanID string) (human humandao.Human, err error)
- func (s *Server) GetHumansFromCache(ctx context.Context, humanIDs ...string) ([]humandao.Human, error)
- func (s *Server) GetReactions(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) HumanCreate(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) HumanGet(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) HumansByID(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) HumansDraft(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) HumansList(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) HumansReview(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) OptionalAuthMiddleware(next http.Handler) http.Handler
- func (s *Server) PostReaction(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) RateLimitMiddleware(next http.Handler) http.Handler
- func (s *Server) ReactionsForHuman(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) SaveHuman(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) ServeHTTP(writer http.ResponseWriter, request *http.Request)
- func (s *Server) UnsaveHuman(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) User(w http.ResponseWriter, r *http.Request) (err error)
- func (s *Server) Version(w http.ResponseWriter, r *http.Request) error
- func (s *Server) ViewHuman(w http.ResponseWriter, r *http.Request) (err error)
- type ServerHTML
- func (s *ServerHTML) HandlerAbout(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) HandlerAdmin(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) HandlerError(w http.ResponseWriter, r *http.Request, e ErrorResponse) error
- func (s *ServerHTML) HandlerGenerate(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) HandlerHuman(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) HandlerHumanAdd(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) HandlerHumanEdit(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) HandlerHumanUpdate(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) HandlerHumans(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) HandlerIndex(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) HandlerLogin(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) HandlerPublish(w http.ResponseWriter, r *http.Request) error
- func (s *ServerHTML) Register(router chi.Router) error
- func (s *ServerHTML) WrapFileServer(fileSystem fs.FS) http.Handler
- type ServerHTMLConfig
- type Socials
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoAuthorization = fmt.Errorf("no authorization token")
Functions ¶
Types ¶
type Authorizer ¶
type ErrorResponse ¶
func NewBadRequestError ¶
func NewBadRequestError(err error) ErrorResponse
func NewForbiddenError ¶
func NewForbiddenError(err error) ErrorResponse
func NewInternalServerError ¶
func NewInternalServerError(err error) ErrorResponse
func NewNotFoundError ¶
func NewNotFoundError(err error) ErrorResponse
func NewTooManyRequestsError ¶
func NewTooManyRequestsError(err error) ErrorResponse
func NewUnauthorizedError ¶
func NewUnauthorizedError(err error) ErrorResponse
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type HTMLResponseAdmin ¶
type HTMLResponseHuman ¶
type HTMLResponseHumans ¶
type HTMLResponseLogin ¶
type HTMLResponseLogin struct {
Base
}
type HttpHandler ¶
type HttpHandler func(http.ResponseWriter, *http.Request) error
func (HttpHandler) Serve ¶
func (h HttpHandler) Serve(errorHandler func(w http.ResponseWriter, r *http.Request, e ErrorResponse) error) func(http.ResponseWriter, *http.Request)
type Human ¶
type Human struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Gender humandao.Gender `json:"gender,omitempty"` Path string `json:"path,omitempty"` ReactionCount humandao.ReactionCount `json:"reactionCount,omitempty"` DOB string `json:"dob,omitempty"` DOD string `json:"dod,omitempty"` Tags []string `json:"tags,omitempty"` Ethnicity []string `json:"ethnicity,omitempty"` BirthLocation string `json:"birthLocation,omitempty"` Location []string `json:"location,omitempty"` InfluencedBy []string `json:"influencedBy,omitempty"` FeaturedImage string `json:"featuredImage,omitempty"` Draft bool `json:"draft,omitempty"` AIGenerated bool `json:"ai_generated,omitempty"` Description string `json:"description,omitempty"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` Affiliates []Affiliate `json:"affiliates"` Socials Socials `json:"socials"` }
type HumanCreateRequest ¶
type HumanCreateRequest struct { Name string `json:"name,omitempty"` Gender string `json:"gender,omitempty"` DOB string `json:"dob,omitempty"` DOD string `json:"dod,omitempty"` Ethnicity []string `json:"ethnicity,omitempty"` Description string `json:"description,omitempty"` Location []string `json:"location,omitempty"` Website string `json:"website,omitempty"` Twitter string `json:"twitter,omitempty"` IMDB string `json:"imdb,omitempty"` Tags []string `json:"tags,omitempty"` ImagePath string `json:"image_path,omitempty"` }
type HumanCreateResponse ¶
type HumanFormFields ¶
HumanFormFields holds helper data to populate the form to add a new human.
type NoOpAuthorizer ¶
type NoOpAuthorizer struct{}
func (NoOpAuthorizer) SessionCookie ¶
func (NoOpAuthorizer) VerifyIDToken ¶
func (NoOpAuthorizer) VerifySessionCookieAndCheckRevoked ¶
type ReactionResponse ¶
type RecentlyViewed ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) DeleteReaction ¶
func (*Server) GetHumanFromCache ¶
func (*Server) GetHumansFromCache ¶
func (*Server) GetReactions ¶
func (*Server) HumanCreate ¶
func (*Server) HumansByID ¶
HumansByID finds all humans given a list of IDs, preserves order. All IDs must be valid, or a HTTP 404 will be returned.
func (*Server) HumansDraft ¶
func (*Server) HumansList ¶
func (*Server) HumansReview ¶
func (*Server) OptionalAuthMiddleware ¶
func (*Server) PostReaction ¶
func (*Server) RateLimitMiddleware ¶
func (*Server) ReactionsForHuman ¶
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(writer http.ResponseWriter, request *http.Request)
func (*Server) UnsaveHuman ¶
type ServerHTML ¶
type ServerHTML struct {
// contains filtered or unexported fields
}
func NewServerHTML ¶
func NewServerHTML(conf ServerHTMLConfig) *ServerHTML
func (*ServerHTML) HandlerAbout ¶
func (s *ServerHTML) HandlerAbout(w http.ResponseWriter, r *http.Request) error
func (*ServerHTML) HandlerAdmin ¶
func (s *ServerHTML) HandlerAdmin(w http.ResponseWriter, r *http.Request) error
func (*ServerHTML) HandlerError ¶
func (s *ServerHTML) HandlerError(w http.ResponseWriter, r *http.Request, e ErrorResponse) error
func (*ServerHTML) HandlerGenerate ¶
func (s *ServerHTML) HandlerGenerate(w http.ResponseWriter, r *http.Request) error
HandlerGenerate takes in the form, and populates it based on the data in the 'source' field.
func (*ServerHTML) HandlerHuman ¶
func (s *ServerHTML) HandlerHuman(w http.ResponseWriter, r *http.Request) error
func (*ServerHTML) HandlerHumanAdd ¶
func (s *ServerHTML) HandlerHumanAdd(w http.ResponseWriter, r *http.Request) error
func (*ServerHTML) HandlerHumanEdit ¶
func (s *ServerHTML) HandlerHumanEdit(w http.ResponseWriter, r *http.Request) error
func (*ServerHTML) HandlerHumanUpdate ¶
func (s *ServerHTML) HandlerHumanUpdate(w http.ResponseWriter, r *http.Request) error
func (*ServerHTML) HandlerHumans ¶
func (s *ServerHTML) HandlerHumans(w http.ResponseWriter, r *http.Request) error
func (*ServerHTML) HandlerIndex ¶
func (s *ServerHTML) HandlerIndex(w http.ResponseWriter, r *http.Request) error
func (*ServerHTML) HandlerLogin ¶
func (s *ServerHTML) HandlerLogin(w http.ResponseWriter, r *http.Request) error
func (*ServerHTML) HandlerPublish ¶
func (s *ServerHTML) HandlerPublish(w http.ResponseWriter, r *http.Request) error
func (*ServerHTML) Register ¶
func (s *ServerHTML) Register(router chi.Router) error
func (*ServerHTML) WrapFileServer ¶
func (s *ServerHTML) WrapFileServer(fileSystem fs.FS) http.Handler
type ServerHTMLConfig ¶
type User ¶
type User struct { ID string `json:"id"` Saved []Saved `json:"saved"` RecentlyViewed []RecentlyViewed `json:"recently_viewed"` }
Click to show internal directories.
Click to hide internal directories.