httpserver

package
v0.0.0-...-9265677 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//nolint:gosec
	FlatTrackSchedulerSecretHeader = "X-FlatTrack-Scheduler-Secret"
)

Variables

This section is empty.

Functions

func GetHTTPresponseBodyContents

func GetHTTPresponseBodyContents(response *http.Response) (output types.JSONMessageResponse)

GetHTTPresponseBodyContents ... convert the body of a HTTP response into a JSONMessageResponse

func GetRequestIP

func GetRequestIP(r *http.Request) (requestIP string)

GetRequestIP ... returns r.RemoteAddr unless RealIPHeader is set

func JSONResponse

func JSONResponse(r *http.Request, w http.ResponseWriter, code int, output types.JSONMessageResponse)

JSONResponse ... form generic JSON responses

Types

type HTTPHeaderBackendAllowTypes

type HTTPHeaderBackendAllowTypes string

HTTPHeaderBackendAllowTypes heads to check for content type

const (
	// HTTPHeaderBackendAllowTypesContentType use the Content-Type http header
	HTTPHeaderBackendAllowTypesContentType HTTPHeaderBackendAllowTypes = "Content-Type"
	// HTTPHeaderBackendAllowTypesAccept use the Accept http header
	HTTPHeaderBackendAllowTypesAccept HTTPHeaderBackendAllowTypes = "Accept"
)

type HTTPServer

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

func NewHTTPServer

func NewHTTPServer(
	db *sql.DB,
	users *users.Manager,
	shoppinglist *shoppinglist.Manager,
	emails *emails.Manager,
	groups *groups.Manager,
	health *health.Manager,
	migrations *migrations.Manager,
	registration *registration.Manager,
	settings *settings.Manager,
	system *system.Manager,
	scheduling *scheduling.Manager,
) (h *HTTPServer)

func (*HTTPServer) DeleteShoppingList

func (h *HTTPServer) DeleteShoppingList(w http.ResponseWriter, r *http.Request)

DeleteShoppingList ... delete a new shopping list by it's id

func (*HTTPServer) DeleteShoppingListItem

func (h *HTTPServer) DeleteShoppingListItem(w http.ResponseWriter, r *http.Request)

DeleteShoppingListItem ... delete a shopping list item by it's id

func (*HTTPServer) DeleteShoppingTag

func (h *HTTPServer) DeleteShoppingTag(w http.ResponseWriter, r *http.Request)

DeleteShoppingTag ... deletes a shopping tag by id

func (*HTTPServer) DeleteUser

func (h *HTTPServer) DeleteUser(w http.ResponseWriter, r *http.Request)

DeleteUser ... delete a user

func (*HTTPServer) GetAllGroups

func (h *HTTPServer) GetAllGroups(w http.ResponseWriter, r *http.Request)

GetAllGroups ... returns a list of all groups

func (*HTTPServer) GetAllShoppingTags

func (h *HTTPServer) GetAllShoppingTags(w http.ResponseWriter, r *http.Request)

GetAllShoppingTags ... responds with all tags used in shopping list items

func (*HTTPServer) GetAllUsers

func (h *HTTPServer) GetAllUsers(w http.ResponseWriter, r *http.Request)

func (*HTTPServer) GetGroup

func (h *HTTPServer) GetGroup(w http.ResponseWriter, r *http.Request)

GetGroup ... returns a group by id

func (*HTTPServer) GetProfile

func (h *HTTPServer) GetProfile(w http.ResponseWriter, r *http.Request)

GetProfile ... returns the authenticated user's profile

func (*HTTPServer) GetSettingsFlatName

func (h *HTTPServer) GetSettingsFlatName(w http.ResponseWriter, r *http.Request)

GetSettingsFlatName ... responds with the name of the flat

func (*HTTPServer) GetSettingsFlatNotes

func (h *HTTPServer) GetSettingsFlatNotes(w http.ResponseWriter, r *http.Request)

GetSettingsFlatNotes ... responds with the notes for flat

func (*HTTPServer) GetSettingsShoppingListNotes

func (h *HTTPServer) GetSettingsShoppingListNotes(w http.ResponseWriter, r *http.Request)

GetSettingsShoppingListNotes ... responds with the notes for shopping lists

func (*HTTPServer) GetShoppingList

func (h *HTTPServer) GetShoppingList(w http.ResponseWriter, r *http.Request)

GetShoppingList ... responds with list of shopping lists

func (*HTTPServer) GetShoppingListItem

func (h *HTTPServer) GetShoppingListItem(w http.ResponseWriter, r *http.Request)

GetShoppingListItem ... responds with list of shopping lists

func (*HTTPServer) GetShoppingListItemTags

func (h *HTTPServer) GetShoppingListItemTags(w http.ResponseWriter, r *http.Request)

GetShoppingListItemTags ... responds with tags used in shopping list items from a list

func (*HTTPServer) GetShoppingListItems

func (h *HTTPServer) GetShoppingListItems(w http.ResponseWriter, r *http.Request)

GetShoppingListItems ... responds with shopping items by list id

func (*HTTPServer) GetShoppingLists

func (h *HTTPServer) GetShoppingLists(w http.ResponseWriter, r *http.Request)

GetShoppingLists ... responds with shopping list by id

func (*HTTPServer) GetShoppingTag

func (h *HTTPServer) GetShoppingTag(w http.ResponseWriter, r *http.Request)

GetShoppingTag ... gets a shopping tag by id

func (*HTTPServer) GetSystemInitialized

func (h *HTTPServer) GetSystemInitialized(w http.ResponseWriter, r *http.Request)

GetSystemInitialized ... check if the server has been initialized

func (*HTTPServer) GetUser

func (h *HTTPServer) GetUser(w http.ResponseWriter, r *http.Request)

GetUser ... get a user by id or email (whatever is provided in the given respective order)

func (*HTTPServer) GetUserConfirm

func (h *HTTPServer) GetUserConfirm(w http.ResponseWriter, r *http.Request)

GetUserConfirm ... returns an account confirm by id

func (*HTTPServer) GetUserConfirmValid

func (h *HTTPServer) GetUserConfirmValid(w http.ResponseWriter, r *http.Request)

GetUserConfirmValid ... returns if an account confirm is valid by id TODO should this exist?

func (*HTTPServer) GetUserConfirms

func (h *HTTPServer) GetUserConfirms(w http.ResponseWriter, r *http.Request)

GetUserConfirms ... returns a list of account confirms TODO should this exist?

func (*HTTPServer) GetVersion

func (h *HTTPServer) GetVersion(w http.ResponseWriter, r *http.Request)

GetVersion ... returns version information about the instance

func (*HTTPServer) HTTP404

func (h *HTTPServer) HTTP404() http.HandlerFunc

HTTP404 ... responds with 404

func (*HTTPServer) HTTPcheckGroupsFromID

func (h *HTTPServer) HTTPcheckGroupsFromID(groupsAllowed ...string) func(http.HandlerFunc) http.HandlerFunc

HTTPcheckGroupsFromID ... middleware for checking if a route can be accessed given a ID and groupID

func (*HTTPServer) HTTPvalidateJWT

func (h *HTTPServer) HTTPvalidateJWT() func(http.HandlerFunc) http.HandlerFunc

HTTPvalidateJWT ... middleware for checking JWT auth token validity

func (*HTTPServer) Healthz

func (h *HTTPServer) Healthz(w http.ResponseWriter, r *http.Request)

Healthz ... HTTP handler for health checks

func (*HTTPServer) Listen

func (h *HTTPServer) Listen()

func (*HTTPServer) PatchProfile

func (h *HTTPServer) PatchProfile(w http.ResponseWriter, r *http.Request)

PatchProfile ... patches a user account their id from their JWT

func (*HTTPServer) PatchShoppingList

func (h *HTTPServer) PatchShoppingList(w http.ResponseWriter, r *http.Request)

PatchShoppingList ... patches an existing shopping list

func (*HTTPServer) PatchShoppingListCompleted

func (h *HTTPServer) PatchShoppingListCompleted(w http.ResponseWriter, r *http.Request)

PatchShoppingListCompleted ... adds an item to a shopping list

func (*HTTPServer) PatchShoppingListItem

func (h *HTTPServer) PatchShoppingListItem(w http.ResponseWriter, r *http.Request)

PatchShoppingListItem ... patches an item in a shopping list

func (*HTTPServer) PatchShoppingListItemObtained

func (h *HTTPServer) PatchShoppingListItemObtained(w http.ResponseWriter, r *http.Request)

PatchShoppingListItemObtained ... patches an item in a shopping list

func (*HTTPServer) PatchUser

func (h *HTTPServer) PatchUser(w http.ResponseWriter, r *http.Request)

PatchUser ... patches a user account by their id

func (*HTTPServer) PatchUserDisabled

func (h *HTTPServer) PatchUserDisabled(w http.ResponseWriter, r *http.Request)

PatchUserDisabled ... patches a user account's disabled field by their id

func (*HTTPServer) PostAdminRegister

func (h *HTTPServer) PostAdminRegister(w http.ResponseWriter, r *http.Request)

PostAdminRegister ... register the instance of FlatTrack

func (*HTTPServer) PostItemToShoppingList

func (h *HTTPServer) PostItemToShoppingList(w http.ResponseWriter, r *http.Request)

PostItemToShoppingList ... adds an item to a shopping list

func (*HTTPServer) PostSchedulerRun

func (h *HTTPServer) PostSchedulerRun(w http.ResponseWriter, r *http.Request)

func (*HTTPServer) PostShoppingList

func (h *HTTPServer) PostShoppingList(w http.ResponseWriter, r *http.Request)

PostShoppingList ... creates a new shopping list to add items to

func (*HTTPServer) PostShoppingTag

func (h *HTTPServer) PostShoppingTag(w http.ResponseWriter, r *http.Request)

PostShoppingTag ... creates a tag name

func (*HTTPServer) PostUser

func (h *HTTPServer) PostUser(w http.ResponseWriter, r *http.Request)

PostUser ... create a user

func (*HTTPServer) PostUserConfirm

func (h *HTTPServer) PostUserConfirm(w http.ResponseWriter, r *http.Request)

PostUserConfirm ... confirm a user account

func (*HTTPServer) PutProfile

func (h *HTTPServer) PutProfile(w http.ResponseWriter, r *http.Request)

PutProfile ... Update a user account their id from their JWT

func (*HTTPServer) PutSettingsFlatNotes

func (h *HTTPServer) PutSettingsFlatNotes(w http.ResponseWriter, r *http.Request)

PutSettingsFlatNotes ... update the notes for flat

func (*HTTPServer) PutSettingsShoppingList

func (h *HTTPServer) PutSettingsShoppingList(w http.ResponseWriter, r *http.Request)

PutSettingsShoppingList ... update the notes for shopping lists

func (*HTTPServer) PutShoppingList

func (h *HTTPServer) PutShoppingList(w http.ResponseWriter, r *http.Request)

PutShoppingList ... updates an existing shopping list

func (*HTTPServer) PutShoppingListItem

func (h *HTTPServer) PutShoppingListItem(w http.ResponseWriter, r *http.Request)

PutShoppingListItem ... updates an item in a shopping list

func (*HTTPServer) PutUser

func (h *HTTPServer) PutUser(w http.ResponseWriter, r *http.Request)

PutUser ... updates a user account by their id

func (*HTTPServer) Root

func (h *HTTPServer) Root(w http.ResponseWriter, r *http.Request)

Root ... /api endpoint

func (*HTTPServer) SetSettingsFlatName

func (h *HTTPServer) SetSettingsFlatName(w http.ResponseWriter, r *http.Request)

SetSettingsFlatName ... update the flat's name

func (*HTTPServer) UpdateShoppingListItemTag

func (h *HTTPServer) UpdateShoppingListItemTag(w http.ResponseWriter, r *http.Request)

UpdateShoppingListItemTag ... updates then tag name used in shopping list items from a list

func (*HTTPServer) UpdateShoppingTag

func (h *HTTPServer) UpdateShoppingTag(w http.ResponseWriter, r *http.Request)

UpdateShoppingTag ... updates a tag name

func (*HTTPServer) UserAuth

func (h *HTTPServer) UserAuth(w http.ResponseWriter, r *http.Request)

UserAuth ... authenticate a user

func (*HTTPServer) UserAuthReset

func (h *HTTPServer) UserAuthReset(w http.ResponseWriter, r *http.Request)

UserAuthReset ... invalidates all JWTs

func (*HTTPServer) UserAuthValidate

func (h *HTTPServer) UserAuthValidate(w http.ResponseWriter, r *http.Request)

UserAuthValidate ... validate an auth token

func (*HTTPServer) UserCanIgroup

func (h *HTTPServer) UserCanIgroup(w http.ResponseWriter, r *http.Request)

UserCanIgroup ... respond whether the current user account is in a group

Jump to

Keyboard shortcuts

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