messaging

package
v0.0.0-...-9b93ea0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Example
package main

import (
	"context"
	"fmt"

	"github.com/protogodev/validate/examples/messaging"
)

func main() {
	var svc messaging.Service = &messaging.Messaging{}
	svc = messaging.ValidateMiddleware(nil)(svc)

	text, err := svc.GetMessage(context.Background(), "123", "00000000-1111-2222-3333-001122334455")
	fmt.Printf("text: %q, err: %v\n", text, err)

	text, err = svc.GetMessage(context.Background(), "", "")
	fmt.Printf("text: %q, err: %v\n", text, err)

}
Output:

text: "user[123]: message[00000000-1111-2222-3333-001122334455]", err: <nil>
text: "", err: userID: INVALID(has an invalid length), messageID: INVALID(invalid UUID)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateMiddleware

func ValidateMiddleware(wrap func(error) error) func(Service) Service

Types

type Messaging

type Messaging struct{}

func (*Messaging) GetMessage

func (m *Messaging) GetMessage(ctx context.Context, userID string, messageID string) (string, error)

type Service

type Service interface {
	// GetMessage get the specified message.
	//
	// @schema:
	//   userID: len(1, 10)
	//   messageID: uuid
	GetMessage(ctx context.Context, userID string, messageID string) (text string, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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