api

package
v0.0.0-...-e672c87 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

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

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

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

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 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

func New

func New(h TaskHandler) (http.Handler, error)

func WithHandler

func WithHandler(th TaskHandler) httpserver.Opt

WithHandler returns an httpserver.Opt that sets the API handler.

Types

type API

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

func (*API) CreateTask

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

func (*API) DeleteTask

func (a *API) DeleteTask(w http.ResponseWriter, r *http.Request, taskID uint64)

func (*API) ListTasks

func (a *API) ListTasks(w http.ResponseWriter, r *http.Request, params ListTasksParams)

func (*API) UpdateTask

func (a *API) UpdateTask(w http.ResponseWriter, r *http.Request, taskID uint64)

type CreateTaskJSONRequestBody

type CreateTaskJSONRequestBody = TaskData

CreateTaskJSONRequestBody defines body for CreateTask for application/json ContentType.

type Error

type Error struct {
	Code    int
	Details string
}

func (*Error) Send

func (e *Error) Send(w http.ResponseWriter)

type ErrorResponse

type ErrorResponse struct {
	// Details Error details
	Details string `json:"details"`
}

ErrorResponse defines model for errorResponse.

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 ListTasksParams

type ListTasksParams struct {
	// Status Filters the tasks by their status
	Status *Status `form:"status,omitempty" json:"status,omitempty"`
}

ListTasksParams defines parameters for ListTasks.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

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 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 {
	// List the available tasks
	// (GET /api/v1/tasks)
	ListTasks(w http.ResponseWriter, r *http.Request, params ListTasksParams)
	// Create a task
	// (POST /api/v1/tasks)
	CreateTask(w http.ResponseWriter, r *http.Request)
	// Delete task by id
	// (DELETE /api/v1/tasks/{taskID})
	DeleteTask(w http.ResponseWriter, r *http.Request, taskID uint64)
	// Update the task
	// (PUT /api/v1/tasks/{taskID})
	UpdateTask(w http.ResponseWriter, r *http.Request, taskID uint64)
}

ServerInterface represents all server handlers.

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) ListTasks

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

ListTasks operation middleware

func (*ServerInterfaceWrapper) UpdateTask

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

UpdateTask operation middleware

type Status

type Status string

Status The task status

const (
	Done    Status = "done"
	Waiting Status = "waiting"
	Working Status = "working"
)

Defines values for Status.

type StdHTTPServerOptions

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

type Task

type Task struct {
	// CreatedAt The task creation date
	CreatedAt time.Time `json:"createdAt"`

	// Description The task description
	Description *string `json:"description,omitempty"`

	// Id The task identifier
	Id uint64 `json:"id"`

	// Status The task status
	Status Status `json:"status"`

	// Title The task title
	Title string `json:"title"`
}

Task defines model for Task.

type TaskData

type TaskData struct {
	// Description The task description
	Description *string `json:"description,omitempty"`

	// Status The task status
	Status Status `json:"status"`

	// Title The task title
	Title string `json:"title"`
}

TaskData defines model for TaskData.

type TaskHandler

type TaskHandler interface {
	ListTasks(context.Context, ListTasksParams) ([]Task, *Error)
	CreateTask(context.Context, TaskData) (Task, *Error)
	DeleteTask(context.Context, uint64) *Error
	UpdateTask(context.Context, uint64, TaskData) (Task, *Error)
}

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 UpdateTaskJSONRequestBody

type UpdateTaskJSONRequestBody = TaskData

UpdateTaskJSONRequestBody defines body for UpdateTask for application/json ContentType.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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