v1

package
v0.0.0-...-0805d90 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(baseUrl string, handler v1.StrictServerInterface) http.Handler

NewRouter creates a new v1 API router.

Types

type ErrorHandler

type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error)

ErrorHandler handles translating errors to HTTP responses.

var (
	DefaultRequestErrorHandler ErrorHandler = func(w http.ResponseWriter, r *http.Request, err error) {
		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusBadRequest)

		e := v1.Error{Type: v1.BadRequest, Description: err.Error()}
		if err := json.NewEncoder(w).Encode(e); err != nil {
			_, _ = fmt.Fprintf(w, "{\"type\":\"%s\",\"description\":\"%s\"}", v1.InternalError, "failed to serialize error")
		}
	}

	DefaultResponseErrorHandler ErrorHandler = func(w http.ResponseWriter, r *http.Request, err error) {
		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusInternalServerError)

		e := v1.Error{Type: v1.InternalError, Description: err.Error()}
		if err := json.NewEncoder(w).Encode(e); err != nil {
			_, _ = fmt.Fprintf(w, "{\"type\":\"%s\",\"description\":\"%s\"}", v1.InternalError, "failed to serialize error")
		}
	}
)

type Server

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

Server is a REST server for the Katana v1 API.

func NewServer

func NewServer(repos []repo.Repository, logger *zap.Logger) (*Server, error)

NewServer creates a new server with pre-defined repositories.

func (*Server) Close

func (s *Server) Close() (err error)

Close cleans up residual data after the server.

func (*Server) GetRepoById

func (*Server) GetRepoMedia

func (*Server) Repos

func (s *Server) Repos() []repo.Repository

Repos returns all repositories available to the server.

type WrapMode

type WrapMode uint

WrapMode is a collection of option flags (integers ORed together).

const (
	// WrapModeBasicImages wraps only basic images (backdrops, posters) for the API model.
	WrapModeBasicImages WrapMode = 1 << iota
)

func (WrapMode) Has

func (wm WrapMode) Has(flag WrapMode) bool

Has checks whether a WrapMode can be addressed from this one.

Jump to

Keyboard shortcuts

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