handlers

package
v0.0.0-...-b9becd8 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UPLOAD_LIMIT = 10000

Functions

func HandleCountries

func HandleCountries(renderer Renderer) http.Handler

func HandleCountry

func HandleCountry(renderer Renderer, repo db.CountryRepo) http.Handler

func HandleDownload

func HandleDownload(
	userRepo db.IndividualRepo,
	azureStorageClient *azblob.Client,
	containerName string,
) http.Handler

func HandleHealth

func HandleHealth(healthzRepo db.HealthzRepo) http.Handler

func HandleHome

func HandleHome(renderer Renderer) http.Handler

func HandleIndividual

func HandleIndividual(renderer Renderer, repo db.IndividualRepo) http.Handler

func HandleIndividualAction

func HandleIndividualAction(repo db.IndividualRepo, action string) http.Handler

func HandleIndividuals

func HandleIndividuals(renderer Renderer, repo db.IndividualRepo) http.Handler

func HandleIndividualsAction

func HandleIndividualsAction(renderer Renderer, repo db.IndividualRepo, action string) http.Handler

func HandleUpload

func HandleUpload(renderer Renderer, individualRepo db.IndividualRepo) http.Handler

Types

type Renderer

type Renderer interface {
	RenderView(w http.ResponseWriter, r *http.Request, templateName string, data viewParams)
}

func NewRenderer

func NewRenderer(templates map[string]*template.Template, enableBetaFeatures bool) Renderer

type RequestContext

type RequestContext struct {
	// Request is the http request
	Request *http.Request
	// Auth is the auth.Interface
	Auth auth.Interface
	// Countries is the list of all countries
	Countries []*api.Country
	// SelectedCountry is the selected country. May be nil
	SelectedCountry *api.Country
	// Session is the current user session
	Session auth.Session
	// AvailableLocales is a list of the available locales
	AvailableLocales map[string]string

	// turn on dev features
	EnableBetaFeatures bool
}

RequestContext encapsulates useful information about the current request.

func (RequestContext) HasSelectedCountryReadPermission

func (r RequestContext) HasSelectedCountryReadPermission() bool

func (RequestContext) HasSelectedCountryWritePermission

func (r RequestContext) HasSelectedCountryWritePermission() bool

func (RequestContext) SelectedCountryID

func (r RequestContext) SelectedCountryID() string

type ViewData

type ViewData map[string]interface{}

ViewData is a map of key/value pairs that can be used to render a view. We can add methods to this type to make it more useful when rendering views.

func (ViewData) Error

func (v ViewData) Error(field string) string

Error returns the error message for the given field.

func (ViewData) ErrorsKey

func (v ViewData) ErrorsKey() string

ErrorsKey returns the key for the errors map in the view data.

func (ViewData) GetErrors

func (v ViewData) GetErrors() validation.ValidationErrors

GetErrors returns a map of field names to error messages.

func (ViewData) HasError

func (v ViewData) HasError(field string) bool

HasError returns true if the given field has an error.

func (ViewData) HasErrors

func (v ViewData) HasErrors() bool

HasErrors returns true if there are any errors

func (ViewData) RequestContext

func (v ViewData) RequestContext() RequestContext

RequestContext returns the request context for the current request.

func (ViewData) RequestContextKey

func (v ViewData) RequestContextKey() string

RequestContextKey returns the key for the request context in the view data.

Jump to

Keyboard shortcuts

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