mkpiphandler

command
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

README

MkPIPHandler (Make Policy Information Point Handler)

MkPIPHandler is an utility to create wrapper for PIP handler for unmarshaling information requests and marshaling responses. It takes handler's schema as input and generates golang package with all necessary processing.

Usage

Usage of mkpiphandler:

$ mkpiphandler [-s <input>] [-d <output>]

Options:

  • -s - schema to generate handler by (default schema.yaml);
  • -d - path to put package to (default is current directory).

Schema

Schema of the PIP handler consists of a package name and endpoints it can process:

package: <pkgName>

endpoints:
  "*":
    args:
    - <argType1>
    - <argType2>
    ...
    - <argTypeN>
    result: <resultType>

The name of package <pkgNamegt> should be valid golang identifier. Code generated by MkPIPHandler goes to subdirectory of output directory with this name (<output>/<pkgNamegt>).

The set of endpoints is a map of string to endpoint definition. Currently, the utility supports only single endpoint with name "*". This endpoint matches any information request.

Endpoint definition includes list of input argument types and output type. All arguments are required. A response can be a value of specified type or error. Available types are:

  • boolean;
  • string - string (up to 65536 characters);
  • integer - 64-bit integer values;
  • float - 64-bit float values;
  • address - IPv4 or IPv6 addresss;
  • network - IPv4 or IPv6 networks (address/cidr);
  • domain - domain name;
  • set of strings - ordered set of strings (up to 65536 entries);
  • set of networks - ordered set of IPv4 and/or IPv6 networks (single set can contain both);
  • set of domains - ordered set of domain names;
  • list of strings - plain list of strings.

Generated Package

The package generated by MkPIPHandler exports handler prototype:

type Handler func(<goArgType1>, <goArgType2>, ..., <goArgTypeN>) (<goResultType>, error)

And wrapper which converts function of Handler type to ServiceHandler required by WithHandler option of "github.com/infobloxopen/themis/pip/server" package:

func WrapHandler(f Handler) server.ServiceHandler {
...
}

Having this in for example handler package user can start custom server like in code below:

package main

import (
	"github.com/infobloxopen/themis/pip/server"
	".../handler"
)

func main() {
	s := server.NewServer(
		WithHandler(handler.WrapHandler(f)),
	)
	if err := s.Bind(); err != nil {
		panic(err)
	}
	if err := s.Serve(); err != nil {
		panic(err)
	}
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pipexample
Package pipexample is a generated PIP server handler package.
Package pipexample is a generated PIP server handler package.
spipexample
Package spipexample is a generated PIP server handler package.
Package spipexample is a generated PIP server handler package.
Package pkg of mkpipsrv utility provides data schema for generator input and generation logic itself.
Package pkg of mkpipsrv utility provides data schema for generator input and generation logic itself.

Jump to

Keyboard shortcuts

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