rest

package
v0.0.0-...-4b6ff60 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package rest provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.0 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, m ServeMux) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

Types

type CreateTask201JSONResponse

type CreateTask201JSONResponse struct {
	CreateTasksResponseJSONResponse
}

func (CreateTask201JSONResponse) VisitCreateTaskResponse

func (response CreateTask201JSONResponse) VisitCreateTaskResponse(w http.ResponseWriter) error

type CreateTask400JSONResponse

type CreateTask400JSONResponse struct{ ErrorResponseJSONResponse }

func (CreateTask400JSONResponse) VisitCreateTaskResponse

func (response CreateTask400JSONResponse) VisitCreateTaskResponse(w http.ResponseWriter) error

type CreateTask500JSONResponse

type CreateTask500JSONResponse struct {
	Error string `json:"error"`
}

func (CreateTask500JSONResponse) VisitCreateTaskResponse

func (response CreateTask500JSONResponse) VisitCreateTaskResponse(w http.ResponseWriter) error

type CreateTaskJSONBody

type CreateTaskJSONBody struct {
	Dates       *Dates    `json:"dates,omitempty"`
	Description string    `json:"description"`
	Priority    *Priority `json:"priority,omitempty"`
}

CreateTaskJSONBody defines parameters for CreateTask.

type CreateTaskJSONRequestBody

type CreateTaskJSONRequestBody CreateTaskJSONBody

CreateTaskJSONRequestBody defines body for CreateTask for application/json ContentType.

type CreateTaskRequestObject

type CreateTaskRequestObject struct {
	Body *CreateTaskJSONRequestBody
}

type CreateTaskResponseObject

type CreateTaskResponseObject interface {
	VisitCreateTaskResponse(w http.ResponseWriter) error
}

type CreateTasksRequest

type CreateTasksRequest struct {
	Dates       *Dates    `json:"dates,omitempty"`
	Description string    `json:"description"`
	Priority    *Priority `json:"priority,omitempty"`
}

CreateTasksRequest defines model for CreateTasksRequest.

type CreateTasksResponse

type CreateTasksResponse struct {
	Task Task `json:"task"`
}

CreateTasksResponse defines model for CreateTasksResponse.

type CreateTasksResponseJSONResponse

type CreateTasksResponseJSONResponse struct {
	Task Task `json:"task"`
}

type Dates

type Dates struct {
	// Due When the task is expected to be due, seconds are dropped.
	Due *time.Time `json:"due"`

	// Start When the task is expected to begin, seconds are dropped.
	Start *time.Time `json:"start"`
}

Dates defines model for Dates.

func (Dates) ToDomain

func (d Dates) ToDomain() internal.Dates

ToDomain returns the domain type defining the internal representation.

type DeleteTask200Response

type DeleteTask200Response struct {
}

func (DeleteTask200Response) VisitDeleteTaskResponse

func (response DeleteTask200Response) VisitDeleteTaskResponse(w http.ResponseWriter) error

type DeleteTask404Response

type DeleteTask404Response struct {
}

func (DeleteTask404Response) VisitDeleteTaskResponse

func (response DeleteTask404Response) VisitDeleteTaskResponse(w http.ResponseWriter) error

type DeleteTask500JSONResponse

type DeleteTask500JSONResponse struct{ ErrorResponseJSONResponse }

func (DeleteTask500JSONResponse) VisitDeleteTaskResponse

func (response DeleteTask500JSONResponse) VisitDeleteTaskResponse(w http.ResponseWriter) error

type DeleteTaskRequestObject

type DeleteTaskRequestObject struct {
	Id googleuuid.UUID `json:"id"`
}

type DeleteTaskResponseObject

type DeleteTaskResponseObject interface {
	VisitDeleteTaskResponse(w http.ResponseWriter) error
}

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse defines model for ErrorResponse.

type ErrorResponseJSONResponse

type ErrorResponseJSONResponse struct {
	Error string `json:"error"`
}

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type Priority

type Priority string

Priority defines model for Priority.

const (
	PriorityHigh   Priority = "high"
	PriorityLow    Priority = "low"
	PriorityMedium Priority = "medium"
	PriorityNone   Priority = "none"
)

Defines values for Priority.

func NewPriority

func NewPriority(p internal.Priority) Priority

NewPriority converts the received domain type to a rest type, when the argument is unknown "none" is used.

func (Priority) MarshalJSON

func (p Priority) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*Priority) ToDomain

func (p *Priority) ToDomain() *internal.Priority

ToDomain returns the domain type defining the internal representation, when Priority is unknown or nil "none" is used.

func (*Priority) UnmarshalJSON

func (p *Priority) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

func (Priority) Validate

func (p Priority) Validate() error

Validate ...

type ReadTask200JSONResponse

type ReadTask200JSONResponse struct{ ReadTasksResponseJSONResponse }

func (ReadTask200JSONResponse) VisitReadTaskResponse

func (response ReadTask200JSONResponse) VisitReadTaskResponse(w http.ResponseWriter) error

type ReadTask404Response

type ReadTask404Response struct {
}

func (ReadTask404Response) VisitReadTaskResponse

func (response ReadTask404Response) VisitReadTaskResponse(w http.ResponseWriter) error

type ReadTask500JSONResponse

type ReadTask500JSONResponse struct{ ErrorResponseJSONResponse }

func (ReadTask500JSONResponse) VisitReadTaskResponse

func (response ReadTask500JSONResponse) VisitReadTaskResponse(w http.ResponseWriter) error

type ReadTaskRequestObject

type ReadTaskRequestObject struct {
	Id googleuuid.UUID `json:"id"`
}

type ReadTaskResponseObject

type ReadTaskResponseObject interface {
	VisitReadTaskResponse(w http.ResponseWriter) error
}

type ReadTasksResponse

type ReadTasksResponse struct {
	Task *Task `json:"task,omitempty"`
}

ReadTasksResponse defines model for ReadTasksResponse.

type ReadTasksResponseJSONResponse

type ReadTasksResponseJSONResponse struct {
	Task *Task `json:"task,omitempty"`
}

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type SearchTask200JSONResponse

type SearchTask200JSONResponse struct {
	SearchTasksResponseJSONResponse
}

func (SearchTask200JSONResponse) VisitSearchTaskResponse

func (response SearchTask200JSONResponse) VisitSearchTaskResponse(w http.ResponseWriter) error

type SearchTask400JSONResponse

type SearchTask400JSONResponse struct{ ErrorResponseJSONResponse }

func (SearchTask400JSONResponse) VisitSearchTaskResponse

func (response SearchTask400JSONResponse) VisitSearchTaskResponse(w http.ResponseWriter) error

type SearchTask500JSONResponse

type SearchTask500JSONResponse struct {
	Error string `json:"error"`
}

func (SearchTask500JSONResponse) VisitSearchTaskResponse

func (response SearchTask500JSONResponse) VisitSearchTaskResponse(w http.ResponseWriter) error

type SearchTaskJSONBody

type SearchTaskJSONBody struct {
	Description *string   `json:"description"`
	From        int64     `json:"from"`
	IsDone      *bool     `json:"isDone"`
	Priority    *Priority `json:"priority,omitempty"`
	Size        int64     `json:"size"`
}

SearchTaskJSONBody defines parameters for SearchTask.

type SearchTaskJSONRequestBody

type SearchTaskJSONRequestBody SearchTaskJSONBody

SearchTaskJSONRequestBody defines body for SearchTask for application/json ContentType.

type SearchTaskRequestObject

type SearchTaskRequestObject struct {
	Body *SearchTaskJSONRequestBody
}

type SearchTaskResponseObject

type SearchTaskResponseObject interface {
	VisitSearchTaskResponse(w http.ResponseWriter) error
}

type SearchTasksRequest

type SearchTasksRequest struct {
	Description *string   `json:"description"`
	From        int64     `json:"from"`
	IsDone      *bool     `json:"isDone"`
	Priority    *Priority `json:"priority,omitempty"`
	Size        int64     `json:"size"`
}

SearchTasksRequest defines model for SearchTasksRequest.

type SearchTasksResponse

type SearchTasksResponse struct {
	Tasks *[]Task `json:"tasks,omitempty"`
	Total *int64  `json:"total,omitempty"`
}

SearchTasksResponse defines model for SearchTasksResponse.

type SearchTasksResponseJSONResponse

type SearchTasksResponseJSONResponse struct {
	Tasks *[]Task `json:"tasks,omitempty"`
	Total *int64  `json:"total,omitempty"`
}

type ServeMux

type ServeMux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

ServeMux is an abstraction of http.ServeMux.

type ServerInterface

type ServerInterface interface {

	// (POST /tasks)
	CreateTask(w http.ResponseWriter, r *http.Request)

	// (POST /tasks/search)
	SearchTask(w http.ResponseWriter, r *http.Request)

	// (DELETE /tasks/{id})
	DeleteTask(w http.ResponseWriter, r *http.Request, id googleuuid.UUID)

	// (GET /tasks/{id})
	ReadTask(w http.ResponseWriter, r *http.Request, id googleuuid.UUID)

	// (PUT /tasks/{id})
	UpdateTask(w http.ResponseWriter, r *http.Request, id googleuuid.UUID)
}

ServerInterface represents all server handlers.

func NewStrictHandler

func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface

func NewStrictHandlerWithOptions

func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictHTTPServerOptions) ServerInterface

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CreateTask

func (siw *ServerInterfaceWrapper) CreateTask(w http.ResponseWriter, r *http.Request)

CreateTask operation middleware

func (*ServerInterfaceWrapper) DeleteTask

func (siw *ServerInterfaceWrapper) DeleteTask(w http.ResponseWriter, r *http.Request)

DeleteTask operation middleware

func (*ServerInterfaceWrapper) ReadTask

func (siw *ServerInterfaceWrapper) ReadTask(w http.ResponseWriter, r *http.Request)

ReadTask operation middleware

func (*ServerInterfaceWrapper) SearchTask

func (siw *ServerInterfaceWrapper) SearchTask(w http.ResponseWriter, r *http.Request)

SearchTask operation middleware

func (*ServerInterfaceWrapper) UpdateTask

func (siw *ServerInterfaceWrapper) UpdateTask(w http.ResponseWriter, r *http.Request)

UpdateTask operation middleware

type StdHTTPServerOptions

type StdHTTPServerOptions struct {
	BaseURL          string
	BaseRouter       ServeMux
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StrictHTTPServerOptions

type StrictHTTPServerOptions struct {
	RequestErrorHandlerFunc  func(w http.ResponseWriter, r *http.Request, err error)
	ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StrictServerInterface

type StrictServerInterface interface {

	// (POST /tasks)
	CreateTask(ctx context.Context, request CreateTaskRequestObject) (CreateTaskResponseObject, error)

	// (POST /tasks/search)
	SearchTask(ctx context.Context, request SearchTaskRequestObject) (SearchTaskResponseObject, error)

	// (DELETE /tasks/{id})
	DeleteTask(ctx context.Context, request DeleteTaskRequestObject) (DeleteTaskResponseObject, error)

	// (GET /tasks/{id})
	ReadTask(ctx context.Context, request ReadTaskRequestObject) (ReadTaskResponseObject, error)

	// (PUT /tasks/{id})
	UpdateTask(ctx context.Context, request UpdateTaskRequestObject) (UpdateTaskResponseObject, error)
}

StrictServerInterface represents all server handlers.

type Task

type Task struct {
	Dates       *Dates          `json:"dates,omitempty"`
	Description string          `json:"description"`
	ID          googleuuid.UUID `json:"id"`
	IsDone      *bool           `json:"isDone,omitempty"`
	Priority    *Priority       `json:"priority,omitempty"`
}

Task defines model for Task.

type TaskHandler

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

TaskHandler ...

func NewTaskHandler

func NewTaskHandler(svc TaskService) *TaskHandler

NewTaskHandler ...

func (*TaskHandler) CreateTask

func (*TaskHandler) DeleteTask

func (*TaskHandler) ReadTask

func (*TaskHandler) SearchTask

func (*TaskHandler) UpdateTask

type TaskService

type TaskService interface {
	By(ctx context.Context, args internal.SearchParams) (internal.SearchResults, error)
	Create(ctx context.Context, params internal.CreateParams) (internal.Task, error)
	Delete(ctx context.Context, id string) error
	ByID(ctx context.Context, id string) (internal.Task, error)
	Update(ctx context.Context, id string, args internal.UpdateParams) error
}

TaskService ...

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

type UpdateTask200Response

type UpdateTask200Response struct {
}

func (UpdateTask200Response) VisitUpdateTaskResponse

func (response UpdateTask200Response) VisitUpdateTaskResponse(w http.ResponseWriter) error

type UpdateTask400JSONResponse

type UpdateTask400JSONResponse struct{ ErrorResponseJSONResponse }

func (UpdateTask400JSONResponse) VisitUpdateTaskResponse

func (response UpdateTask400JSONResponse) VisitUpdateTaskResponse(w http.ResponseWriter) error

type UpdateTask404Response

type UpdateTask404Response struct {
}

func (UpdateTask404Response) VisitUpdateTaskResponse

func (response UpdateTask404Response) VisitUpdateTaskResponse(w http.ResponseWriter) error

type UpdateTask500JSONResponse

type UpdateTask500JSONResponse struct {
	Error string `json:"error"`
}

func (UpdateTask500JSONResponse) VisitUpdateTaskResponse

func (response UpdateTask500JSONResponse) VisitUpdateTaskResponse(w http.ResponseWriter) error

type UpdateTaskJSONBody

type UpdateTaskJSONBody struct {
	Dates       *Dates    `json:"dates,omitempty"`
	Description *string   `json:"description,omitempty"`
	IsDone      *bool     `json:"isDone,omitempty"`
	Priority    *Priority `json:"priority,omitempty"`
}

UpdateTaskJSONBody defines parameters for UpdateTask.

type UpdateTaskJSONRequestBody

type UpdateTaskJSONRequestBody UpdateTaskJSONBody

UpdateTaskJSONRequestBody defines body for UpdateTask for application/json ContentType.

type UpdateTaskRequestObject

type UpdateTaskRequestObject struct {
	Id   googleuuid.UUID `json:"id"`
	Body *UpdateTaskJSONRequestBody
}

type UpdateTaskResponseObject

type UpdateTaskResponseObject interface {
	VisitUpdateTaskResponse(w http.ResponseWriter) error
}

type UpdateTasksRequest

type UpdateTasksRequest struct {
	Dates       *Dates    `json:"dates,omitempty"`
	Description *string   `json:"description,omitempty"`
	IsDone      *bool     `json:"isDone,omitempty"`
	Priority    *Priority `json:"priority,omitempty"`
}

UpdateTasksRequest defines model for UpdateTasksRequest.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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