todo

package
v0.0.0-...-e6546de Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Username = "anonymous"

Username is a temporary value for all user name fields until we get proper authentication in place

Variables

This section is empty.

Functions

func FailureMiddleware

func FailureMiddleware(next http.Handler) http.Handler

FailureMiddleware is a simple middleware to simulate HTTP errors

Types

type Config

type Config struct {
	TodoURL        string
	OcAgentHost    string
	EnableFailures bool
	EnableTracing  bool
}

Config holds server configuration

func NewConfig

func NewConfig() *Config

NewConfig loads config from environment variables

type DeleteRes

type DeleteRes struct {
	Success bool `json:"success"`
}

DeleteRes data model.

func FromGRPCDeleteRes

func FromGRPCDeleteRes(grpcRes *todomgrpb.DeleteTodoRes) *DeleteRes

FromGRPCDeleteRes returns new DeleteRes object based on gRPC DTO from the upstream todo-manager service

func (*DeleteRes) Bind

func (t *DeleteRes) Bind(r *http.Request) error

Bind allows to set additional properties on Todo object; not used here

func (*DeleteRes) Render

func (t *DeleteRes) Render(w http.ResponseWriter, r *http.Request) error

Render allows to modify the way Todo object is rendered to text; not used here

type Router

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

Router is a registry of go-chi routes supported by Todo

func NewRouter

func NewRouter(todoManagerAddr string) *Router

NewRouter returns new go-chi router with initialized gRPC client

func (*Router) CreateTodo

func (t *Router) CreateTodo(w http.ResponseWriter, r *http.Request)

CreateTodo creates a new todo for a given user

func (*Router) DeleteTodo

func (t *Router) DeleteTodo(w http.ResponseWriter, r *http.Request)

DeleteTodo deletes a todo with specified user and todo ID

func (*Router) GetRouter

func (t *Router) GetRouter() chi.Router

GetRouter returns configuredsub-router for Todo resources

func (*Router) GetTodo

func (t *Router) GetTodo(w http.ResponseWriter, r *http.Request)

GetTodo gets a todo with specified user and todo ID

func (*Router) ListTodos

func (t *Router) ListTodos(w http.ResponseWriter, r *http.Request)

ListTodos lists all todos owned by a user

func (*Router) UpdateTodo

func (t *Router) UpdateTodo(w http.ResponseWriter, r *http.Request)

UpdateTodo updates a todo with specified user and todo ID

type Todo

type Todo struct {
	ID   string `json:"id"`
	Text string `json:"text"`
	Done bool   `json:"done"`
}

Todo data model.

func FromGRPCTodo

func FromGRPCTodo(grpcTodo *todomgrpb.Todo) (*Todo, string)

FromGRPCTodo returns new Todo object and owner info based on gRPC DTO from the upstream todo-manager service

func (*Todo) Bind

func (t *Todo) Bind(r *http.Request) error

Bind allows to set additional properties on Todo object; not used here

func (*Todo) Render

func (t *Todo) Render(w http.ResponseWriter, r *http.Request) error

Render allows to modify the way Todo object is rendered to text; not used here

func (*Todo) ToGRPCTodo

func (t *Todo) ToGRPCTodo(owner string) *todomgrpb.Todo

ToGRPCTodo return gRPC DTO for the upstream todo-manager service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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