api

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Error = errs.Class("api server")

Error is an error class for API http server error.

Functions

func GetAPIIdentifier

func GetAPIIdentifier(ctx context.Context) string

GetAPIIdentifier return the authenticated identity of the client.

func ServeJSONError

func ServeJSONError(logger *zap.Logger, w http.ResponseWriter, status int, err error)

ServeJSONError writes JSON error to response output stream.

func SetAPIIdentifier

func SetAPIIdentifier(ctx context.Context, identity string) context.Context

SetAPIIdentifier sets the satellite identifier to the context.

Types

type Config

type Config struct {
	Address string   `help:"public address to listen on" default:":10000"`
	Keys    []string `help:"List of user:secret pairs to connect to service endpoints."`
}

Config holds API endpoint configuration.

type Server

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

Server represents storjscan API web server.

architecture: Endpoint

func NewServer

func NewServer(log *zap.Logger, listener net.Listener, apiKeys map[string]string) *Server

NewServer creates new API server instance.

func (*Server) Close

func (server *Server) Close() error

Close closes server and underlying listener.

func (*Server) LogRoutes

func (server *Server) LogRoutes() error

LogRoutes print out registered routes to the log.

func (*Server) NewAPI

func (server *Server) NewAPI(path string, register func(*mux.Router))

NewAPI creates new API route and register endpoint methods.

func (*Server) Run

func (server *Server) Run(ctx context.Context) (err error)

Run runs the server that host api endpoints.

Jump to

Keyboard shortcuts

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