Documentation ¶
Overview ¶
Package todos provides primitives to interact with the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen version v1.8.3 DO NOT EDIT.
Package todos provides primitives to interact with the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen version v1.8.3 DO NOT EDIT.
Index ¶
- Constants
- func GetErrorF(errMsg string, err error) error
- func IsDriverSupported(driver string) bool
- func RegisterHandlers(router EchoRouter, si ServerInterface)
- func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)
- type CreateTodoJSONBody
- type CreateTodoJSONRequestBody
- type EchoRouter
- type Error
- type ErrorService
- type GetTodosParams
- type NewTodo
- type PGX
- func (db *PGX) Close()
- func (db *PGX) Count() (int32, error)
- func (db *PGX) Create(todo NewTodo) (*Todo, error)
- func (db *PGX) Delete(id int32) error
- func (db *PGX) Exist(id int32) bool
- func (db *PGX) Get(id int32) (*Todo, error)
- func (db *PGX) GetMaxId() (int32, error)
- func (db *PGX) List(offset, limit int) ([]*Todo, error)
- func (db *PGX) Update(id int32, todo Todo) (*Todo, error)
- type ServerInterface
- type ServerInterfaceWrapper
- func (w *ServerInterfaceWrapper) CreateTodo(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) DeleteTodo(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GetTodo(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GetTodos(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) UpdateTodo(ctx echo.Context) error
- type Service
- func (s Service) CreateTodo(ctx echo.Context) error
- func (s Service) DeleteTodo(ctx echo.Context, todoId int32) error
- func (s Service) GetMaxId(ctx echo.Context) error
- func (s Service) GetTodo(ctx echo.Context, todoId int32) error
- func (s Service) GetTodos(ctx echo.Context, params GetTodosParams) error
- func (s Service) UpdateTodo(ctx echo.Context, todoId int32) error
- type Storage
- type Todo
Constants ¶
const DefaultMaxId = 2
Variables ¶
This section is empty.
Functions ¶
func IsDriverSupported ¶
func RegisterHandlers ¶
func RegisterHandlers(router EchoRouter, si ServerInterface)
RegisterHandlers adds each server route to the EchoRouter.
func RegisterHandlersWithBaseURL ¶
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)
Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.
Types ¶
type CreateTodoJSONBody ¶
type CreateTodoJSONBody NewTodo
CreateTodoJSONBody defines parameters for CreateTodo.
type CreateTodoJSONRequestBody ¶
type CreateTodoJSONRequestBody CreateTodoJSONBody
CreateTodoJSONRequestBody defines body for CreateTodo for application/json ContentType.
type EchoRouter ¶
type EchoRouter interface { CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route }
This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration
type ErrorService ¶
type ErrorService struct { Err error `json:"err" ` Status int `json:"status" ` Msg string `json:"msg" ` }
func (*ErrorService) Error ¶
func (e *ErrorService) Error() string
type GetTodosParams ¶
type GetTodosParams struct { // maximum number of results to return Limit *int32 `json:"limit,omitempty"` }
GetTodosParams defines parameters for GetTodos.
type PGX ¶
type ServerInterface ¶
type ServerInterface interface { // Returns all Todos // (GET /todos) GetTodos(ctx echo.Context, params GetTodosParams) error // (POST /todos) CreateTodo(ctx echo.Context) error // (DELETE /todos/{todoId}) DeleteTodo(ctx echo.Context, todoId int32) error // (GET /todos/{todoId}) GetTodo(ctx echo.Context, todoId int32) error // (PUT /todos/{todoId}) UpdateTodo(ctx echo.Context, todoId int32) error }
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
ServerInterfaceWrapper converts echo contexts to parameters.
func (*ServerInterfaceWrapper) CreateTodo ¶
func (w *ServerInterfaceWrapper) CreateTodo(ctx echo.Context) error
CreateTodo converts echo context to params.
func (*ServerInterfaceWrapper) DeleteTodo ¶
func (w *ServerInterfaceWrapper) DeleteTodo(ctx echo.Context) error
DeleteTodo converts echo context to params.
func (*ServerInterfaceWrapper) GetTodo ¶
func (w *ServerInterfaceWrapper) GetTodo(ctx echo.Context) error
GetTodo converts echo context to params.
func (*ServerInterfaceWrapper) GetTodos ¶
func (w *ServerInterfaceWrapper) GetTodos(ctx echo.Context) error
GetTodos converts echo context to params.
func (*ServerInterfaceWrapper) UpdateTodo ¶
func (w *ServerInterfaceWrapper) UpdateTodo(ctx echo.Context) error
UpdateTodo converts echo context to params.
type Service ¶
func (Service) CreateTodo ¶
CreateTodo will store the NewTodo task in the store to test it with curl you can try : curl -XPOST -H "Content-Type: application/json" -d '{"task":"learn Linux"}' 'http://localhost:8080/todos' curl -XPOST -H "Content-Type: application/json" -d '{"task":""}' 'http://localhost:8080/todos'
func (Service) DeleteTodo ¶
DeleteTodo will remove the given todoID entry from the store, and if not present will return 400 Bad Request curl -v -XDELETE -H "Content-Type: application/json" 'http://localhost:8080/todos/3' -> 204 No Content if present and delete it curl -v -XDELETE -H "Content-Type: application/json" 'http://localhost:8080/todos/93333' -> 400 Bad Request
func (Service) GetMaxId ¶
GetMaxId returns the greatest todos id used by now curl -H "Content-Type: application/json" 'http://localhost:8080/todos/maxid'
func (Service) GetTodos ¶
func (s Service) GetTodos(ctx echo.Context, params GetTodosParams) error
GetTodos will retrieve all Todos in the store and return then to test it with curl you can try : curl -H "Content-Type: application/json" 'http://localhost:8080/todos' |json_pp
func (Service) UpdateTodo ¶
UpdateTodo will store the modified information in the store for the given todoId curl -v -XPUT -H "Content-Type: application/json" -d '{"id": 3, "task":"learn Linux", "completed": true}' 'http://localhost:8080/todos/3' curl -v -XPUT -H "Content-Type: application/json" -d '{"id": 3, "task":"learn Linux", "completed": false}' 'http://localhost:8080/todos/3'
type Storage ¶
type Storage interface { // List returns the list of existing todos with the given offset and limit. List(offset, limit int) ([]*Todo, error) // Get returns the todos with the specified todos ID. Get(id int32) (*Todo, error) // GetMaxId returns the maximum value of todos id existing in store. GetMaxId() (int32, error) // Exist returns true only if a todos with the specified id exists in store. Exist(id int32) bool // Count returns the total number of todos. Count() (int32, error) // Create saves a new todos in the storage. Create(todo NewTodo) (*Todo, error) // Update updates the todos with given ID in the storage. Update(id int32, todo Todo) (*Todo, error) // Delete removes the todos with given ID from the storage. Delete(id int32) error // Close terminates properly the connection to the backend Close() }
Storage is an interface to different implementation of persistence for Todos