api

package
v0.0.0-...-646d846 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: Unlicense Imports: 14 Imported by: 0

Documentation

Overview

Package api is the API server backed by jsonrest-go. It contains routing, handlers, and middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(s *Server) jsonrest.Middleware

AuthMiddleware handles account authentication. If a request isn't authenticated, the endpoint handler is not called.

func PanicRecoveryMiddleware

func PanicRecoveryMiddleware() jsonrest.Middleware

PanicRecoveryMiddleware catches and returns any panics that occur in the endpoint.

Types

type Config

type Config struct {
	Database *pgxpool.Pool
	Sessions *session.Service

	DumpErrors bool // render full error in response
}

Config is the server configuration and dependencies.

type Server

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

Server is an API server.

func NewServer

func NewServer(cfg *Config) *Server

NewServer configures a new API server.

func (*Server) Protocol

func (s *Server) Protocol() protocol.P

Protocol returns the response protocol helper.

func (*Server) Repo

func (s *Server) Repo() *repo.Client

Repo returns the repo client.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements the http.Handler interface.

func (*Server) Sessions

func (s *Server) Sessions() *session.Service

Sessions returns the sessions service.

Directories

Path Synopsis
Package protocol translates domain objects to their API response format.
Package protocol translates domain objects to their API response format.

Jump to

Keyboard shortcuts

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