ports

package
v0.0.0-...-78a6f96 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

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

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

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

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

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

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

Index

Constants

View Source
const (
	BearerAuthScopes = "bearerAuth.Scopes"
)

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, r chi.Router) http.Handler

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

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

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

HandlerWithOptions creates http.Handler with additional options

func NewCreateNoteRequest

func NewCreateNoteRequest(server string, body CreateNoteJSONRequestBody) (*http.Request, error)

NewCreateNoteRequest calls the generic CreateNote builder with application/json body

func NewCreateNoteRequestWithBody

func NewCreateNoteRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewCreateNoteRequestWithBody generates requests for CreateNote with any type of body

func NewDeleteNoteRequest

func NewDeleteNoteRequest(server string, noteUUID openapi_types.UUID) (*http.Request, error)

NewDeleteNoteRequest generates requests for DeleteNote

func NewGetNoteRequest

func NewGetNoteRequest(server string, noteUUID openapi_types.UUID) (*http.Request, error)

NewGetNoteRequest generates requests for GetNote

func NewGetNotesRequest

func NewGetNotesRequest(server string) (*http.Request, error)

NewGetNotesRequest generates requests for GetNotes

func NewUpdateNoteRequest

func NewUpdateNoteRequest(server string, noteUUID openapi_types.UUID, body UpdateNoteJSONRequestBody) (*http.Request, error)

NewUpdateNoteRequest calls the generic UpdateNote builder with application/json body

func NewUpdateNoteRequestWithBody

func NewUpdateNoteRequestWithBody(server string, noteUUID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error)

NewUpdateNoteRequestWithBody generates requests for UpdateNote with any type of body

Types

type ChiServerOptions

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

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) CreateNote

func (c *Client) CreateNote(ctx context.Context, body CreateNoteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) CreateNoteWithBody

func (c *Client) CreateNoteWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) DeleteNote

func (c *Client) DeleteNote(ctx context.Context, noteUUID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetNote

func (c *Client) GetNote(ctx context.Context, noteUUID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetNotes

func (c *Client) GetNotes(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) UpdateNote

func (c *Client) UpdateNote(ctx context.Context, noteUUID openapi_types.UUID, body UpdateNoteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) UpdateNoteWithBody

func (c *Client) UpdateNoteWithBody(ctx context.Context, noteUUID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// GetNotes request
	GetNotes(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// CreateNoteWithBody request with any body
	CreateNoteWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	CreateNote(ctx context.Context, body CreateNoteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// DeleteNote request
	DeleteNote(ctx context.Context, noteUUID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetNote request
	GetNote(ctx context.Context, noteUUID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error)

	// UpdateNoteWithBody request with any body
	UpdateNoteWithBody(ctx context.Context, noteUUID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	UpdateNote(ctx context.Context, noteUUID openapi_types.UUID, body UpdateNoteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) CreateNoteWithBodyWithResponse

func (c *ClientWithResponses) CreateNoteWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateNoteResponse, error)

CreateNoteWithBodyWithResponse request with arbitrary body returning *CreateNoteResponse

func (*ClientWithResponses) CreateNoteWithResponse

func (c *ClientWithResponses) CreateNoteWithResponse(ctx context.Context, body CreateNoteJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateNoteResponse, error)

func (*ClientWithResponses) DeleteNoteWithResponse

func (c *ClientWithResponses) DeleteNoteWithResponse(ctx context.Context, noteUUID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteNoteResponse, error)

DeleteNoteWithResponse request returning *DeleteNoteResponse

func (*ClientWithResponses) GetNoteWithResponse

func (c *ClientWithResponses) GetNoteWithResponse(ctx context.Context, noteUUID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetNoteResponse, error)

GetNoteWithResponse request returning *GetNoteResponse

func (*ClientWithResponses) GetNotesWithResponse

func (c *ClientWithResponses) GetNotesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetNotesResponse, error)

GetNotesWithResponse request returning *GetNotesResponse

func (*ClientWithResponses) UpdateNoteWithBodyWithResponse

func (c *ClientWithResponses) UpdateNoteWithBodyWithResponse(ctx context.Context, noteUUID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateNoteResponse, error)

UpdateNoteWithBodyWithResponse request with arbitrary body returning *UpdateNoteResponse

func (*ClientWithResponses) UpdateNoteWithResponse

func (c *ClientWithResponses) UpdateNoteWithResponse(ctx context.Context, noteUUID openapi_types.UUID, body UpdateNoteJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateNoteResponse, error)

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// GetNotesWithResponse request
	GetNotesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetNotesResponse, error)

	// CreateNoteWithBodyWithResponse request with any body
	CreateNoteWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateNoteResponse, error)

	CreateNoteWithResponse(ctx context.Context, body CreateNoteJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateNoteResponse, error)

	// DeleteNoteWithResponse request
	DeleteNoteWithResponse(ctx context.Context, noteUUID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteNoteResponse, error)

	// GetNoteWithResponse request
	GetNoteWithResponse(ctx context.Context, noteUUID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetNoteResponse, error)

	// UpdateNoteWithBodyWithResponse request with any body
	UpdateNoteWithBodyWithResponse(ctx context.Context, noteUUID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateNoteResponse, error)

	UpdateNoteWithResponse(ctx context.Context, noteUUID openapi_types.UUID, body UpdateNoteJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateNoteResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type CreateNoteJSONRequestBody

type CreateNoteJSONRequestBody = PostNote

CreateNoteJSONRequestBody defines body for CreateNote for application/json ContentType.

type CreateNoteResponse

type CreateNoteResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSONDefault  *Error
}

func ParseCreateNoteResponse

func ParseCreateNoteResponse(rsp *http.Response) (*CreateNoteResponse, error)

ParseCreateNoteResponse parses an HTTP response from a CreateNoteWithResponse call

func (CreateNoteResponse) Status

func (r CreateNoteResponse) Status() string

Status returns HTTPResponse.Status

func (CreateNoteResponse) StatusCode

func (r CreateNoteResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type DeleteNoteResponse

type DeleteNoteResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSONDefault  *Error
}

func ParseDeleteNoteResponse

func ParseDeleteNoteResponse(rsp *http.Response) (*DeleteNoteResponse, error)

ParseDeleteNoteResponse parses an HTTP response from a DeleteNoteWithResponse call

func (DeleteNoteResponse) Status

func (r DeleteNoteResponse) Status() string

Status returns HTTPResponse.Status

func (DeleteNoteResponse) StatusCode

func (r DeleteNoteResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Error

type Error struct {
	Message string `json:"message"`
	Slug    string `json:"slug"`
}

Error defines model for Error.

type GetNoteResponse

type GetNoteResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Note
	JSONDefault  *Error
}

func ParseGetNoteResponse

func ParseGetNoteResponse(rsp *http.Response) (*GetNoteResponse, error)

ParseGetNoteResponse parses an HTTP response from a GetNoteWithResponse call

func (GetNoteResponse) Status

func (r GetNoteResponse) Status() string

Status returns HTTPResponse.Status

func (GetNoteResponse) StatusCode

func (r GetNoteResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetNotesResponse

type GetNotesResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Notes
	JSONDefault  *Error
}

func ParseGetNotesResponse

func ParseGetNotesResponse(rsp *http.Response) (*GetNotesResponse, error)

ParseGetNotesResponse parses an HTTP response from a GetNotesWithResponse call

func (GetNotesResponse) Status

func (r GetNotesResponse) Status() string

Status returns HTTPResponse.Status

func (GetNotesResponse) StatusCode

func (r GetNotesResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type HttpServer

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

func NewHttpServer

func NewHttpServer(noteRepository domain.NoteRepository) HttpServer

func (HttpServer) CreateNote

func (h HttpServer) CreateNote(w http.ResponseWriter, r *http.Request)

func (HttpServer) DeleteNote

func (h HttpServer) DeleteNote(w http.ResponseWriter, r *http.Request, noteUUID openapi_types.UUID)

func (HttpServer) GetNote

func (h HttpServer) GetNote(w http.ResponseWriter, r *http.Request, noteUUID openapi_types.UUID)

func (HttpServer) GetNotes

func (h HttpServer) GetNotes(w http.ResponseWriter, r *http.Request)

func (HttpServer) UpdateNote

func (h HttpServer) UpdateNote(w http.ResponseWriter, r *http.Request, noteUUID openapi_types.UUID)

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 Note

type Note struct {
	Description string             `json:"description"`
	Time        time.Time          `json:"time"`
	Title       string             `json:"title"`
	Uuid        openapi_types.UUID `json:"uuid"`
}

Note defines model for Note.

type Notes

type Notes struct {
	Notes []Note `json:"notes"`
}

Notes defines model for Notes.

type PostNote

type PostNote struct {
	Description string `json:"description"`
	Title       string `json:"title"`
}

PostNote defines model for PostNote.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

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 ServerInterface

type ServerInterface interface {

	// (GET /notes)
	GetNotes(w http.ResponseWriter, r *http.Request)

	// (POST /notes)
	CreateNote(w http.ResponseWriter, r *http.Request)

	// (DELETE /notes/{noteUUID})
	DeleteNote(w http.ResponseWriter, r *http.Request, noteUUID openapi_types.UUID)

	// (GET /notes/{noteUUID})
	GetNote(w http.ResponseWriter, r *http.Request, noteUUID openapi_types.UUID)

	// (PUT /notes/{noteUUID})
	UpdateNote(w http.ResponseWriter, r *http.Request, noteUUID openapi_types.UUID)
}

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

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

CreateNote operation middleware

func (*ServerInterfaceWrapper) DeleteNote

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

DeleteNote operation middleware

func (*ServerInterfaceWrapper) GetNote

GetNote operation middleware

func (*ServerInterfaceWrapper) GetNotes

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

GetNotes operation middleware

func (*ServerInterfaceWrapper) UpdateNote

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

UpdateNote operation middleware

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 Unimplemented

type Unimplemented struct{}

func (Unimplemented) CreateNote

func (_ Unimplemented) CreateNote(w http.ResponseWriter, r *http.Request)

(POST /notes)

func (Unimplemented) DeleteNote

func (_ Unimplemented) DeleteNote(w http.ResponseWriter, r *http.Request, noteUUID openapi_types.UUID)

(DELETE /notes/{noteUUID})

func (Unimplemented) GetNote

func (_ Unimplemented) GetNote(w http.ResponseWriter, r *http.Request, noteUUID openapi_types.UUID)

(GET /notes/{noteUUID})

func (Unimplemented) GetNotes

func (_ Unimplemented) GetNotes(w http.ResponseWriter, r *http.Request)

(GET /notes)

func (Unimplemented) UpdateNote

func (_ Unimplemented) UpdateNote(w http.ResponseWriter, r *http.Request, noteUUID openapi_types.UUID)

(PUT /notes/{noteUUID})

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 UpdateNoteJSONRequestBody

type UpdateNoteJSONRequestBody = PostNote

UpdateNoteJSONRequestBody defines body for UpdateNote for application/json ContentType.

type UpdateNoteResponse

type UpdateNoteResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSONDefault  *Error
}

func ParseUpdateNoteResponse

func ParseUpdateNoteResponse(rsp *http.Response) (*UpdateNoteResponse, error)

ParseUpdateNoteResponse parses an HTTP response from a UpdateNoteWithResponse call

func (UpdateNoteResponse) Status

func (r UpdateNoteResponse) Status() string

Status returns HTTPResponse.Status

func (UpdateNoteResponse) StatusCode

func (r UpdateNoteResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

Jump to

Keyboard shortcuts

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