rest

package
v0.0.0-...-4a1e664 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(server *Server, services RegisterParams)

Types

type FactSvc

type FactSvc interface {
	Find(ctx context.Context, topic facts.TopicType) (facts.Topic, error)
}

FactSvc defines the fact Service.

type GetCatFactResponse

type GetCatFactResponse struct {
	Fact string `json:"fact"`
}

type GetDogFactResponse

type GetDogFactResponse struct {
	Fact string `json:"fact"`
}

type GetEntertainmentFactResponse

type GetEntertainmentFactResponse struct {
	Fact string `json:"fact"`
}

type GetHandler

type GetHandler func(r *http.Request, s *Server, args map[string]interface{}) (interface{}, error)

GetHandler defines the HTTP GET Handlers.

type GetTrivialFactResponse

type GetTrivialFactResponse struct {
	Fact string `json:"fact"`
}

type PostHandler

type PostHandler func(r *http.Request, s *Server, args map[string]interface{}) (string, error)

PostHandler definres the HTTP POST Handlers.

type RegisterParams

type RegisterParams struct {
	Fact FactSvc
}

type RegisteredPath

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

RegisteredPath defines the type used when a path is registered.

func (*RegisteredPath) Get

func (r *RegisteredPath) Get(opID string, handler GetHandler) *RegisteredPath

type Server

type Server struct {
	Router   *mux.Router
	BasePath string
}

func NewServer

func NewServer(basePath string) *Server

func (*Server) RegisterGetHandler

func (s *Server) RegisterGetHandler(path string, router *mux.Router, handler GetHandler, args []string) *mux.Route

func (*Server) RegisterPath

func (s *Server) RegisterPath(path string, router *mux.Router, args ...string) *RegisteredPath

Jump to

Keyboard shortcuts

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