serverhelper

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BODY_HASH = "BodyHash"
View Source
const Issuer = "SimpleInvoker"
View Source
const Subject = "pterergate-service"
View Source
const TokenExpireDuration time.Duration = 5 * time.Minute
View Source
const USER_NAME = "UserName"

Variables

This section is empty.

Functions

func CalcMsgHash

func CalcMsgHash(msg string) string

func Setup

func Setup()

func Teardown

func Teardown()

Types

type CommonMessage

type CommonMessage struct {
	UserName string `json:"username"`
	BodyHash string `json:"bodyhash"`
}

claim

type CommonRequest

type CommonRequest struct {
	Header RequestHeader `json:"RequestHeader"`
	Body   string        `json:"RequestBody"`
}

Request

{
  "RequestHeader":{},
  "RequestBody":{}
}

type CommonResponse

type CommonResponse struct {
	Header ResponseHeader `json:"ResponseHeader"`
	Body   string         `json:"ResponseBody"`
}

Response

{
 "ResponseHeader":{},
 "ResponseBody":{}
}

type IRequest

type IRequest interface{}

type IResponse

type IResponse interface{}

func ReturnErrorResponse

func ReturnErrorResponse(requestId string, code string, message string) IResponse

type RequestHandler

type RequestHandler func(header RequestHeader, requestBody string) (responseBody string, err error)

type RequestHeader

type RequestHeader struct {
	RequestId string `json:"RequestId"`
	Version   string `json:"Version"`
	BodyHash  string `json:"Sign"`
	Timestamp string `json:"Timestamp"`
	Module    string `json:"Module"`
	Action    string `json:"Action"`
}

type ResponseHeader

type ResponseHeader struct {
	RequestId string `json:"RequestId"`
	Code      string `json:"Code"`
	Message   string `json:"Message"`
}

type SimpleInvoker

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

func NewSimpleInvoker

func NewSimpleInvoker() *SimpleInvoker

func (*SimpleInvoker) Post

func (s *SimpleInvoker) Post(url string, userName string, requestBody string) (string, error)

type SimpleServer

type SimpleServer struct {
	ServerPort uint16
	// contains filtered or unexported fields
}

func NewSimpleServer

func NewSimpleServer(serverPort uint16, handlerMap map[string]RequestHandler) *SimpleServer

func (*SimpleServer) Serve

func (s *SimpleServer) Serve() error

func (*SimpleServer) Shutdown

func (s *SimpleServer) Shutdown() error

func (*SimpleServer) ShutdownWithDuration

func (s *SimpleServer) ShutdownWithDuration(duration time.Duration) error

Jump to

Keyboard shortcuts

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