gateway

package
v0.0.0-...-7f33b96 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: AGPL-3.0 Imports: 33 Imported by: 0

README

Go API Server for swagger

PrImBoard (Private Image Board) can be best described as an image board for all the picures and videos you have taken. You can invite users to the board and share specific images with them or your family members!

Overview

This server was generated by the [swagger-codegen] (https://github.com/swagger-api/swagger-codegen) project.
By using the OpenAPI-Spec from a remote server, you can easily generate a server stub.

To see how to make this your own, look here:

README

  • API version: 1.0.0
  • Build date: 2019-11-29T12:40:25.493Z[GMT]
Running the server

To run the server, follow these simple steps:

go run main.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeCommentRequest

func DecodeCommentRequest(w http.ResponseWriter, r *http.Request, c models.Comment) (models.Comment, int)

DecodeCommentRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeCommentsRequest

func DecodeCommentsRequest(w http.ResponseWriter, r *http.Request, c []models.Comment) ([]models.Comment, int)

DecodeCommentsRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeIPFSNodeRequest

func DecodeIPFSNodeRequest(w http.ResponseWriter, r *http.Request, ipfs models.IPFSNode) (models.IPFSNode, int)

DecodeIPFSNodeRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeMediaEventMapRequest

func DecodeMediaEventMapRequest(w http.ResponseWriter, r *http.Request) (models.MediaEventMap, int)

DecodeMediaEventMapRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeMediaGroupMapRequest

func DecodeMediaGroupMapRequest(w http.ResponseWriter, r *http.Request) (models.MediaGroupMap, int)

DecodeMediaGroupMapRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeMediaRequest

func DecodeMediaRequest(w http.ResponseWriter, r *http.Request, m models.Media) (models.Media, int)

DecodeMediaRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeMediasRequest

func DecodeMediasRequest(w http.ResponseWriter, r *http.Request) ([]models.Media, int)

DecodeMediasRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeStringsRequest

func DecodeStringsRequest(w http.ResponseWriter, r *http.Request, u []string) ([]string, int)

DecodeStringsRequest decodes the api request into the passed user slice responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeTagEventMapRequest

func DecodeTagEventMapRequest(w http.ResponseWriter, r *http.Request) (models.TagEventMap, int)

DecodeTagEventMapRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeTagMediaMapRequest

func DecodeTagMediaMapRequest(w http.ResponseWriter, r *http.Request) (models.TagMediaMap, int)

DecodeTagMediaMapRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeTagRequest

func DecodeTagRequest(w http.ResponseWriter, r *http.Request, t models.Tag) (models.Tag, int)

DecodeTagRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeTagStringRequest

func DecodeTagStringRequest(w http.ResponseWriter, r *http.Request, t string) (string, int)

DecodeTagStringRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeTagsRequest

func DecodeTagsRequest(w http.ResponseWriter, r *http.Request, t []models.Tag) ([]models.Tag, int)

DecodeTagsRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeUserGroupRequest

func DecodeUserGroupRequest(w http.ResponseWriter, r *http.Request, ug models.UserGroup) (models.UserGroup, int)

DecodeUserGroupRequest decodes the api request into the passed object responds with decode error if occurs status 0 => ok || status 1 => error

func DecodeUserGroupsRequest

func DecodeUserGroupsRequest(w http.ResponseWriter, r *http.Request, ugs []models.UserGroup) ([]models.UserGroup, int)

DecodeUserGroupsRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error

func HashPassword

func HashPassword(password string) (hashedPassword string)

HashPassword hashes the passed passwort using bcrypt

func Logger

func Logger(inner http.Handler, name string) http.Handler

Logger logs the request

func MatchesBcrypt

func MatchesBcrypt(password string, hash string) error

MatchesBcrypt verifies, that a given string is equal to a encrypted string

func ParseIDs

func ParseIDs(ids []string) ([]primitive.ObjectID, error)

ParseIDs parses a slice of hex ids into primitive.ObjectIDs

func RemoveString

func RemoveString(s []string, r string) []string

RemoveString removes a given string from a given slice

func UnParseIDs

func UnParseIDs(ids []primitive.ObjectID) []string

UnParseIDs parses a slice of hex ids into primitive.ObjectIDs

Types

type AppGateway

type AppGateway struct {
	Router             *mux.Router
	DB                 *mongo.Database
	Config             *infrastructure.APIGatewayConfig
	Ctx                context.Context
	Nodes              map[primitive.ObjectID]*models.Node // stores all authenticated nodes
	Sessions           []*iModels.Session
	HTTPClient         *http.Client
	KeycloakClient     gocloak.GoCloak
	KeycloakToken      *gocloak.JWT
	KeycloakTokenCache map[string]*gocloak.RetrospecTokenResult
}

AppGateway struct to maintain database connection and router

func (*AppGateway) AddCommentByMediaID

func (g *AppGateway) AddCommentByMediaID(w http.ResponseWriter, r *http.Request)

AddCommentByMediaID appends a comment to the specified media

func (*AppGateway) AddDescriptionByMediaID

func (g *AppGateway) AddDescriptionByMediaID(w http.ResponseWriter, r *http.Request)

AddDescriptionByMediaID adds the description to the media

func (*AppGateway) AddEvent

func (g *AppGateway) AddEvent(w http.ResponseWriter, r *http.Request)

AddEvent handles the webrequest for Event creation

func (*AppGateway) AddMedia

func (g *AppGateway) AddMedia(w http.ResponseWriter, r *http.Request)

AddMedia handles the webrequest for Media creation

func (*AppGateway) AddNode

func (g *AppGateway) AddNode(w http.ResponseWriter, r *http.Request)

AddNode handles the webrequest for Node creation

func (*AppGateway) AddTag

func (g *AppGateway) AddTag(w http.ResponseWriter, r *http.Request)

AddTag handles the webrequest for Tag creation

func (*AppGateway) AddTagByMediaID

func (g *AppGateway) AddTagByMediaID(w http.ResponseWriter, r *http.Request)

AddTagByMediaID appends a tag to the specified media creates a new tag if not in the tag document

func (*AppGateway) AddTagsByMediaID

func (g *AppGateway) AddTagsByMediaID(w http.ResponseWriter, r *http.Request)

AddTagsByMediaID appends multiple tags to the specified media creates a new tag if not in the tag document

func (*AppGateway) AddTimestampByMediaID

func (g *AppGateway) AddTimestampByMediaID(w http.ResponseWriter, r *http.Request)

AddTimestampByMediaID adds the creation date to the media

func (*AppGateway) AddTitleByMediaID

func (g *AppGateway) AddTitleByMediaID(w http.ResponseWriter, r *http.Request)

AddTitleByMediaID adds the title to the media

func (*AppGateway) AddUserGroup

func (g *AppGateway) AddUserGroup(w http.ResponseWriter, r *http.Request)

AddUserGroup handles the webrequest for usergroup creation

func (*AppGateway) AddUserToUserGroupByID

func (g *AppGateway) AddUserToUserGroupByID(w http.ResponseWriter, r *http.Request)

AddUserToUserGroupByID adds a User to the specified usergroup

func (*AppGateway) AddUsersToUserGroupByID

func (g *AppGateway) AddUsersToUserGroupByID(w http.ResponseWriter, r *http.Request)

AddUsersToUserGroupByID adds a User to the specified usergroup

func (*AppGateway) Authenticate

func (g *AppGateway) Authenticate(h http.Handler, logout bool) http.Handler

Authenticate is a middleware to pre-authenticate routes via the session token if logout is true, no new session token is beeing generated

func (*AppGateway) Connect

func (g *AppGateway) Connect()

Connect initializes a mongodb connection

func (*AppGateway) DeleteEventByID

func (g *AppGateway) DeleteEventByID(w http.ResponseWriter, r *http.Request)

DeleteEventByID handles the webrequest for Event deletion

func (*AppGateway) DeleteMediaByID

func (g *AppGateway) DeleteMediaByID(w http.ResponseWriter, r *http.Request)

DeleteMediaByID handles the webrequest for Media deletion

func (*AppGateway) DeleteNodeByID

func (g *AppGateway) DeleteNodeByID(w http.ResponseWriter, r *http.Request)

DeleteNodeByID handles the webrequest for Node deletion

func (*AppGateway) DeleteTagByID

func (g *AppGateway) DeleteTagByID(w http.ResponseWriter, r *http.Request)

DeleteTagByID handles the webrequest for Tag deletion

func (*AppGateway) DeleteUserGroupByID

func (g *AppGateway) DeleteUserGroupByID(w http.ResponseWriter, r *http.Request)

DeleteUserGroupByID handles the webrequest for usergroup deletion

func (*AppGateway) GenerateInvite

func (g *AppGateway) GenerateInvite(w http.ResponseWriter, r *http.Request)

GenerateInvite handles the webrequest for creating a new invite

func (*AppGateway) GetEventByID

func (g *AppGateway) GetEventByID(w http.ResponseWriter, r *http.Request)

GetEventByID handles the webrequest for receiving Event model by id

func (*AppGateway) GetEvents

func (g *AppGateway) GetEvents(w http.ResponseWriter, r *http.Request)

GetEvents handles the webrequest for receiving all events

func (*AppGateway) GetEventsByName

func (g *AppGateway) GetEventsByName(w http.ResponseWriter, r *http.Request)

GetEventsByName returns available Events by their name, starting with

func (*AppGateway) GetMedia

func (g *AppGateway) GetMedia(w http.ResponseWriter, r *http.Request)

GetMedia handles the webrequest for receiving all media

func (*AppGateway) GetMediaByID

func (g *AppGateway) GetMediaByID(w http.ResponseWriter, r *http.Request)

GetMediaByID handles the webrequest for receiving Media model by id

func (*AppGateway) GetMediaByIDs

func (g *AppGateway) GetMediaByIDs(w http.ResponseWriter, r *http.Request)

GetMediaByIDs handles the webrequest for receiving Media models by ids

func (*AppGateway) GetNodeByID

func (g *AppGateway) GetNodeByID(w http.ResponseWriter, r *http.Request)

GetNodeByID handles the webrequest for receiving Node model by id

func (*AppGateway) GetNodes

func (g *AppGateway) GetNodes(w http.ResponseWriter, r *http.Request)

GetNodes handles the webrequest for receiving all nodes

func (*AppGateway) GetSession

func (g *AppGateway) GetSession(token string) *iModels.Session

GetSession returns the session object for the passed token

func (*AppGateway) GetSessionByUser

func (g *AppGateway) GetSessionByUser(user string) *iModels.Session

GetSessionByUser Returns the session for the passed user if exist

func (*AppGateway) GetSessionByUsername

func (g *AppGateway) GetSessionByUsername(user string) *iModels.Session

GetSessionByUsername returns the session for the passed username if exist

func (*AppGateway) GetTagByID

func (g *AppGateway) GetTagByID(w http.ResponseWriter, r *http.Request)

GetTagByID handles the webrequest for receiving Tag model by id

func (*AppGateway) GetTags

func (g *AppGateway) GetTags(w http.ResponseWriter, r *http.Request)

GetTags returns all Tags available

func (*AppGateway) GetTagsByName

func (g *AppGateway) GetTagsByName(w http.ResponseWriter, r *http.Request)

GetTagsByName returns available Tags by their name, starting with

func (*AppGateway) GetUserGroupAPI

func (g *AppGateway) GetUserGroupAPI(w http.ResponseWriter, db *mongo.Database, ug *models.UserGroup) int

GetUserGroupAPI handles possible errors during the select and writes Responses

func (*AppGateway) GetUserGroupByID

func (g *AppGateway) GetUserGroupByID(w http.ResponseWriter, r *http.Request)

GetUserGroupByID handles the webrequest for receiving usergroup model by id

func (*AppGateway) GetUserGroups

func (g *AppGateway) GetUserGroups(w http.ResponseWriter, r *http.Request)

GetUserGroups returns all groups, the current user is assigned to

func (*AppGateway) GetUserGroupsByName

func (g *AppGateway) GetUserGroupsByName(w http.ResponseWriter, r *http.Request)

GetUserGroupsByName returns available Tags by their name, starting with

func (*AppGateway) GetUserPermission

func (g *AppGateway) GetUserPermission(username string, ownerOnly bool) bson.M

GetUserPermission parses the permissionfilter and returns it

func (*AppGateway) GetUserPermissionW

func (g *AppGateway) GetUserPermissionW(w http.ResponseWriter, ownerOnly bool) bson.M

GetUserPermissionW parses the permissionfilter and returns it it reads the username from passed response writer

func (*AppGateway) Initialize

func (g *AppGateway) Initialize(config infrastructure.APIGatewayConfig)

Initialize initializes application related content - mongodb connection initialization - router initialization

func (*AppGateway) MapEventsToMedia

func (g *AppGateway) MapEventsToMedia(w http.ResponseWriter, r *http.Request)

MapEventsToMedia maps an media slice to each event entry

func (*AppGateway) MapGroupsToMedia

func (g *AppGateway) MapGroupsToMedia(w http.ResponseWriter, r *http.Request)

MapGroupsToMedia maps an media slice to each event entry

func (*AppGateway) MapTagsToEvents

func (g *AppGateway) MapTagsToEvents(w http.ResponseWriter, r *http.Request)

MapTagsToEvents maps a slice of Tags to a slice of events

func (*AppGateway) MapTagsToMedia

func (g *AppGateway) MapTagsToMedia(w http.ResponseWriter, r *http.Request)

MapTagsToMedia adds a list of tags to a list of media

func (*AppGateway) NewSession

func (g *AppGateway) NewSession(user string, db *mongo.Database, token string) *iModels.Session

NewSession initializes a new Session (if not exists) for the passed user otherwise it updates the token

func (*AppGateway) ReadSessionCookie

func (g *AppGateway) ReadSessionCookie(w *http.ResponseWriter, r *http.Request) string

ReadSessionCookie reads the stoken cookie from the request and returns the value

func (*AppGateway) RemoveSessionByToken

func (g *AppGateway) RemoveSessionByToken(token string)

RemoveSessionByToken finds the session with the given token and removes it from the cached session slice

func (*AppGateway) RemoveUserFromUserGroupByID

func (g *AppGateway) RemoveUserFromUserGroupByID(w http.ResponseWriter, r *http.Request)

RemoveUserFromUserGroupByID adds a User to the specified usergroup

func (*AppGateway) RemoveUsersFromUserGroupByID

func (g *AppGateway) RemoveUsersFromUserGroupByID(w http.ResponseWriter, r *http.Request)

RemoveUsersFromUserGroupByID adds a User to the specified usergroup

func (*AppGateway) Run

func (g *AppGateway) Run(addr string)

Run starts the application on the passed address with the inherited router WARN: router must be initialized first

func (*AppGateway) UpdateEventByID

func (g *AppGateway) UpdateEventByID(w http.ResponseWriter, r *http.Request)

UpdateEventByID handles the webrequest for updating the Event with the passed request body

func (*AppGateway) UpdateMediaByHash

func (g *AppGateway) UpdateMediaByHash(w http.ResponseWriter, r *http.Request)

UpdateMediaByHash handles the webrequest for updating the Media with the passed request body

func (*AppGateway) UpdateMediaByID

func (g *AppGateway) UpdateMediaByID(w http.ResponseWriter, r *http.Request)

UpdateMediaByID handles the webrequest for updating the Media with the passed request body

func (*AppGateway) UpdateNodeByID

func (g *AppGateway) UpdateNodeByID(w http.ResponseWriter, r *http.Request)

UpdateNodeByID handles the webrequest for updating the Node with the passed request body

func (*AppGateway) UpdateTagByID

func (g *AppGateway) UpdateTagByID(w http.ResponseWriter, r *http.Request)

UpdateTagByID handles the webrequest for updating the Tag with the passed request body

func (*AppGateway) UpdateUserGroupByID

func (g *AppGateway) UpdateUserGroupByID(w http.ResponseWriter, r *http.Request)

UpdateUserGroupByID handles the webrequest for updating the usergroup with the passed request body

func (*AppGateway) UploadMedia

func (g *AppGateway) UploadMedia(w http.ResponseWriter, r *http.Request)

UploadMedia handles the webrequest for uploading a file to the api

Jump to

Keyboard shortcuts

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