rest

package
v0.0.0-...-f26ca9b Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Package rest is responsible for rest communication layer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CorsHandler

func CorsHandler(w http.ResponseWriter, r *http.Request)

CorsHandler swagger:route OPTIONS /

Handler to respond to CORS preflight requests

Responses:

200: OK

func FromJSON

func FromJSON(i interface{}, r io.Reader) error

FromJSON deserializes the object from JSON string in an io.Reader to the given interface

func NewAPIContext

func NewAPIContext(bindAddress *string, dataContext *application.DataContext) *http.Server

NewAPIContext returns a new APIContext handler with the given logger

func ToJSON

func ToJSON(i interface{}, w io.Writer) error

ToJSON serializes the given interface into a string based JSON format

Types

type APIContext

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

APIContext struct gathers necessary information for the APIContext

func (*APIContext) AddConversation

func (apiContext *APIContext) AddConversation(rw http.ResponseWriter, r *http.Request)

AddConversation creates a new conversation for a trip.

func (*APIContext) AddMessage

func (apiContext *APIContext) AddMessage(rw http.ResponseWriter, r *http.Request)

AddMessage creates a new message to the conversation.

func (*APIContext) AddRequest

func (apiContext *APIContext) AddRequest(rw http.ResponseWriter, r *http.Request)

AddRequest creates a new request on the system

func (*APIContext) AddTrip

func (apiContext *APIContext) AddTrip(rw http.ResponseWriter, r *http.Request)

AddTrip creates a new trip on the system

func (*APIContext) AddUser

func (apiContext *APIContext) AddUser(rw http.ResponseWriter, r *http.Request)

AddUser creates a new user on the system

func (*APIContext) ConfirmUser

func (apiContext *APIContext) ConfirmUser(rw http.ResponseWriter, r *http.Request)

ConfirmUser confirms a user if found

func (*APIContext) GetConversation

func (apiContext *APIContext) GetConversation(rw http.ResponseWriter, r *http.Request)

GetConversation gets a specific conversation within a trip between the supplier and the requester

func (*APIContext) GetCountries

func (apiContext *APIContext) GetCountries(rw http.ResponseWriter, r *http.Request)

GetCountries gets country list

func (*APIContext) GetCountry

func (apiContext *APIContext) GetCountry(rw http.ResponseWriter, r *http.Request)

GetCountry gets a single country if found

func (*APIContext) GetRequest

func (apiContext *APIContext) GetRequest(rw http.ResponseWriter, r *http.Request)

GetRequest gets a single request based on the id

func (*APIContext) GetRequests

func (apiContext *APIContext) GetRequests(rw http.ResponseWriter, r *http.Request)

GetRequests gets all requests based on the query parameters

func (*APIContext) GetTrip

func (apiContext *APIContext) GetTrip(rw http.ResponseWriter, r *http.Request)

GetTrip Gets a single trip with all the details

func (*APIContext) GetTrips

func (apiContext *APIContext) GetTrips(rw http.ResponseWriter, r *http.Request)

GetTrips gets all the trips within the given country and optionally the given origin and destination

func (*APIContext) GetUser

func (apiContext *APIContext) GetUser(rw http.ResponseWriter, r *http.Request)

GetUser gets a single user if found

func (*APIContext) Index

func (apiContext *APIContext) Index(rw http.ResponseWriter, r *http.Request)

Index returns OK handles GET requests

func (*APIContext) Live

func (apiContext *APIContext) Live(rw http.ResponseWriter, _ *http.Request)

Live handles GET requests

func (*APIContext) Login

func (apiContext *APIContext) Login(w http.ResponseWriter, r *http.Request)

Login handles the login request

func (*APIContext) Ready

func (apiContext *APIContext) Ready(rw http.ResponseWriter, _ *http.Request)

Ready handles GET requests

func (*APIContext) Refresh

func (apiContext *APIContext) Refresh(w http.ResponseWriter, r *http.Request)

Refresh handles the refresh request, and refreshes the validity period of the token

func (*APIContext) RelateRequestToTrip

func (apiContext *APIContext) RelateRequestToTrip(rw http.ResponseWriter, r *http.Request)

RelateRequestToTrip creates a new conversation connecting a request and a trip

func (*APIContext) UpdateApproval

func (apiContext *APIContext) UpdateApproval(rw http.ResponseWriter, r *http.Request)

UpdateApproval updates the approval status of the conversation.

func (*APIContext) Version

func (apiContext *APIContext) Version(rw http.ResponseWriter, r *http.Request)

Version returns the version info for the service by reading from a static file

type Claims

type Claims struct {
	UserID   string               `json:"userid"`
	UserName string               `json:"username"`
	Payload  jwt.RegisteredClaims `json:"payload"`
}

Claims represents the data for a user login

func (Claims) Valid

func (c Claims) Valid() error

Valid checks the validity of the claims

type GenericError

type GenericError struct {
	Message string `json:"message"`
}

GenericError is a generic error message returned by a server

Directories

Path Synopsis
Package dto is the package that defines types for data transfer
Package dto is the package that defines types for data transfer
Package errors contains the generic errors for the REST adapter
Package errors contains the generic errors for the REST adapter
Package mappers is the package that maps objects back and fort between dto and domain
Package mappers is the package that maps objects back and fort between dto and domain
Package middleware is the package that holds the middleware logict for rest layer
Package middleware is the package that holds the middleware logict for rest layer

Jump to

Keyboard shortcuts

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