svcserver

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: MIT Imports: 3 Imported by: 0

README

svcserver

The service server

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize(cont []byte, save interface{}) error

Deserialize is the standard way to decode objects. correspond to Serialize().

func Serialize

func Serialize(obj interface{}) ([]byte, error)

Serialize is the standard way to encode objects. currently JSON without any indentation.

Types

type AuthorizedHandler

type AuthorizedHandler func(requestbody []byte, auth SignatureInfo) (interface{}, error)

AuthorizedHandler is the function executed when a call should be authorized first

type Handler

type Handler func(requestbody []byte) (interface{}, error)

Handler is the function executed when a call matches its name

type ServiceError

type ServiceError struct {
	ErrorMessage string `json:"errmsg"`
}

ServiceError is the standard error response

type ServiceServer

type ServiceServer struct {
	Address       string
	Mux           *http.ServeMux
	PingRewritten bool
}

ServiceServer is the server instance

func NewServiceServer

func NewServiceServer(addr string) ServiceServer

NewServiceServer creates a service server

func (ServiceServer) AuthorizedCallable

func (ss ServiceServer) AuthorizedCallable(name string, handler AuthorizedHandler)

AuthorizedCallable sets a callable function and its handler

func (ServiceServer) Callable

func (ss ServiceServer) Callable(name string, handler Handler)

Callable sets a callable function and its handler

func (ServiceServer) StartServing

func (ss ServiceServer) StartServing() error

StartServing starts the http server according to the info of ss

type SignatureInfo

type SignatureInfo struct {
	Key  string
	Sign string
}

SignatureInfo is the necessary information for checking signature of request.

Jump to

Keyboard shortcuts

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