api

package
v0.0.0-...-4796da1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken = errors.New("token is invalid")
	ErrExpiredToken = errors.New("token has expired")
)

Functions

This section is empty.

Types

type API

type API struct {
	Router *mux.Router
	// contains filtered or unexported fields
}

structure of the API

func New

func New(config *Config, svc service.Service, router *mux.Router, errors model.ErrorJson) (*API, error)

New returns the api settings

func (*API) DeleteUserConfiguration

func (a *API) DeleteUserConfiguration(w http.ResponseWriter, r *http.Request)

endpoint for get user configuration

func (*API) DeleteUserInformation

func (a *API) DeleteUserInformation(w http.ResponseWriter, r *http.Request)

endpoint for delete userInformation

func (*API) GetImage

func (a *API) GetImage(w http.ResponseWriter, r *http.Request)

endpoint for store userInformation

func (*API) GetItems

func (a *API) GetItems() ([]model.Item, error)

for all Items enums

func (*API) GetItemsAll

func (a *API) GetItemsAll(w http.ResponseWriter, r *http.Request)

Endpoint for all Item enums

func (*API) GetItemsBack

func (a *API) GetItemsBack(w http.ResponseWriter, r *http.Request)

Endpoint for back Item enums

func (*API) GetItemsFront

func (a *API) GetItemsFront(w http.ResponseWriter, r *http.Request)

Endpoint for Front Item enums

func (*API) GetOrderHistory

func (a *API) GetOrderHistory(w http.ResponseWriter, r *http.Request)

func (*API) GetUserConfiguration

func (a *API) GetUserConfiguration(w http.ResponseWriter, r *http.Request)

endpoint for get user configuration

func (*API) GetUserInformation

func (a *API) GetUserInformation(w http.ResponseWriter, r *http.Request)

endpoint for get userInformation

func (*API) Login

func (a *API) Login(w http.ResponseWriter, r *http.Request)

Login endpoints responsible from user login

func (*API) RefreshToken

func (a *API) RefreshToken(w http.ResponseWriter, r *http.Request)

Login endpoints responsible from user login

func (*API) SignUp

func (a *API) SignUp(w http.ResponseWriter, r *http.Request)

Register endpoints responsible from user register

func (*API) StoreUserConfiguration

func (a *API) StoreUserConfiguration(w http.ResponseWriter, r *http.Request)

endpoint for store user configuration

func (*API) StoreUserInformation

func (a *API) StoreUserInformation(w http.ResponseWriter, r *http.Request)

endpoint for store userInformation

func (*API) UpdateUserConfiguration

func (a *API) UpdateUserConfiguration(w http.ResponseWriter, r *http.Request)

endpoint for update user configuration

func (*API) UpdateUserInformation

func (a *API) UpdateUserInformation(w http.ResponseWriter, r *http.Request)

endpoint for update userInformation

type Config

type Config struct {
	Domain        string `yaml:"domain"`
	SigningSecret string `yaml:"signing_secret"`
	ImagePath     string `yaml:"imagePath"`
	Enums         struct {
		Front []map[string]string `yaml:"front"`
		Back  []map[string]string `yaml:"back"`
	} `yaml:"enum"`
	PythonBackendAddress string `yaml:"python_backend_address"`
	FakeApiAddress       string `yaml:"fake_api_address"`
}

API configuration

type ContextKey

type ContextKey string

ContextKey implements type for context key

const ContextJWTKey ContextKey = "jwt"

ContextJWTKey is the key for the jwt context value

type Payload

type Payload struct {
	Email     string    `json:"email"`
	IssuedAt  time.Time `json:"issued_at"`
	ExpiredAt time.Time `json:"expired_at"`
}

Payload contains the payload data of the token

func NewPayload

func NewPayload(email string, duration time.Duration) (*Payload, error)

NewPayload creates a new token payload with a specific username and duration

func (*Payload) Valid

func (payload *Payload) Valid() error

Valid checks if the token payload is valid or not

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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