Back to godoc.org

Package proto

v0.3.0
Latest Go to latest

The highest tagged major version is .

Published: Sep 7, 2020 | License: GPL3 | Module: github.com/creekorful/open-dydns

Index

Variables

var ErrAliasAlreadyExist = echo.NewHTTPError(409, "alias already exist")

ErrAliasAlreadyExist is returned when user already own the wanted alias

var ErrAliasNotFound = echo.NewHTTPError(404, "alias not found")

ErrAliasNotFound is returned when the wanted alias cannot be found

var ErrAliasTaken = echo.NewHTTPError(409, "alias already taken")

ErrAliasTaken is returned when the wanted alias is already taken by someone else

var ErrDomainNotFound = echo.NewHTTPError(404, "requested domain not found")

ErrDomainNotFound is returned when the alias to register use non supported / not existing domain

var ErrInvalidParameters = echo.NewHTTPError(400, "invalid request parameter(s)")

ErrInvalidParameters is returned when the given request is invalid

type APIContract

type APIContract interface {
	// Authenticate user using given credential
	// this either return the JWT token or an error if something goes wrong
	// POST /sessions
	Authenticate(cred CredentialsDto) (TokenDto, error)
	// GetAliases return user current aliases
	// GET /aliases
	GetAliases(token TokenDto) ([]AliasDto, error)
	// RegisterAlias register a new alias for the user
	// POST /aliases
	RegisterAlias(token TokenDto, alias AliasDto) (AliasDto, error)
	// UpdateAlias update the user existing alias
	// PUT /aliases/{name}
	UpdateAlias(token TokenDto, alias AliasDto) (AliasDto, error)
	// DeleteAlias delete the user given alias
	// DELETE /aliases/{name}
	DeleteAlias(token TokenDto, name string) error

	// GetDomains return the list of available / supported domains
	// for alias creation
	// GET /domains
	GetDomains(token TokenDto) ([]DomainDto, error)
}

APIContract defined the API served by the Daemon

type AliasDto

type AliasDto struct {
	Domain string `json:"domain"`
	Value  string `json:"value"`
}

AliasDto represent a DyDNS alias

type CredentialsDto

type CredentialsDto struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

CredentialsDto represent the credentials when issuing a authentication request

type DomainDto

type DomainDto struct {
	Domain string `json:"domain"`
}

DomainDto represent a domain usable to create alias on the Daemon

type ErrorDto

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

ErrorDto is the generic error response in case of API error TODO make my own error mapper

func (ErrorDto) Error

func (e ErrorDto) Error() string

type TokenDto

type TokenDto struct {
	Token string `json:"token"`
}

TokenDto represent the object that encapsulate the JWT token when issuing a authentication request

type UserContext

type UserContext struct {
	UserID uint
}

UserContext represent the JWT token payload and identify the logged in user in secured endpoints

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier