kitsune

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: BSD-2-Clause Imports: 8 Imported by: 1

README

kitsune

REST API server and client utilities.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(w http.ResponseWriter, rej any)

func Delete added in v0.9.0

func Delete(endpoint string) (r io.ReadCloser, err error)

func Forbidden

func Forbidden(w http.ResponseWriter, rej any)

func Get added in v0.9.0

func Get(endpoint string) (r io.ReadCloser, err error)

func GetAuthorization added in v0.9.0

func GetAuthorization(h http.Header) (token string, ok bool)

func InternalServerError

func InternalServerError(w http.ResponseWriter, rej any)

func ParseRequest

func ParseRequest(w http.ResponseWriter, r *http.Request, req any) (ok bool)

func ParseResponse

func ParseResponse(r io.ReadCloser, resp any) (err error)

func Post added in v0.9.0

func Post(endpoint string, req any) (r io.ReadCloser, err error)

func Put added in v0.9.0

func Put(endpoint string, body io.Reader) (r io.ReadCloser, err error)

func Reject

func Reject(w http.ResponseWriter, rej any, code int)

func Respond

func Respond(w http.ResponseWriter, resp any)

func SetAuthorization added in v0.9.0

func SetAuthorization(h http.Header, token string)

func SetLogFile added in v0.7.0

func SetLogFile(w io.Writer)

func Teapot

func Teapot(w http.ResponseWriter, rej any)

func TeapotHandler

func TeapotHandler(rej any) http.Handler

func Unauthorized

func Unauthorized(w http.ResponseWriter, rej any)

Types

type Client added in v0.0.2

type Client struct {
	Context  context.Context
	Endpoint string
	Header   http.Header
}

func (Client) Delete added in v0.9.0

func (c Client) Delete() (r io.ReadCloser, err error)

func (Client) Get added in v0.9.0

func (c Client) Get() (r io.ReadCloser, err error)

func (Client) Post added in v0.9.0

func (c Client) Post(req any) (r io.ReadCloser, err error)

func (Client) Put added in v0.9.0

func (c Client) Put(body io.Reader) (r io.ReadCloser, err error)

type ResponseError

type ResponseError struct {
	StatusCode int
	Message    json.RawMessage
}

func (*ResponseError) Error

func (re *ResponseError) Error() string

Jump to

Keyboard shortcuts

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