helloworld

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RequestValidators = []httpoption.NamedValidator{
	httpoption.Op("SayHello", ValidateSayHelloRequest(func(req *SayHelloRequest) v.Schema {
		return v.Schema{
			v.F("name", req.Name): v.All(
				v.LenString(0, 10).Msg("length exceeds 10"),
				v.Match(regexp.MustCompile(`^\w+$`)).Msg("invalid name format"),
			),
		}
	})),
}

Functions

func MakeEndpointOfSayHello

func MakeEndpointOfSayHello(s Service) endpoint.Endpoint

MakeEndpointOfSayHello creates the endpoint for s.SayHello.

func NewHTTPRouter

func NewHTTPRouter(svc Service, codecs httpcodec.Codecs, opts ...httpoption.Option) chi.Router

func OASv2APIDoc

func OASv2APIDoc(schema oas2.Schema) string

func ValidateSayHelloRequest

func ValidateSayHelloRequest(newSchema func(*SayHelloRequest) validating.Schema) httpoption.Validator

ValidateSayHelloRequest creates a validator for SayHelloRequest.

Types

type Greeter

type Greeter struct{}

func (*Greeter) SayHello

func (g *Greeter) SayHello(ctx context.Context, name string) (string, error)

type HTTPClient

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

func NewHTTPClient

func NewHTTPClient(codecs httpcodec.Codecs, httpClient *http.Client, baseURL string) (*HTTPClient, error)

func (*HTTPClient) SayHello

func (c *HTTPClient) SayHello(ctx context.Context, name string) (message string, err error)

type SayHelloRequest

type SayHelloRequest struct {
	Name string `json:"name"`
}

type SayHelloResponse

type SayHelloResponse struct {
	Message string `json:"message"`
	Err     error  `json:"-"`
}

func (*SayHelloResponse) Body

func (r *SayHelloResponse) Body() interface{}

func (*SayHelloResponse) Failed

func (r *SayHelloResponse) Failed() error

Failed implements endpoint.Failer.

type Service

type Service interface {
	// SayHello says hello to the given name.
	//kun:op POST /messages
	SayHello(ctx context.Context, name string) (message string, err error)
}

Service is used for saying hello.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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