stonelizard

package module
v0.0.0-...-5c9fbd2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MPL-2.0 Imports: 29 Imported by: 7

README

Stonelizard is a REST Services middleware golang package.

GoDoc

From the HTTP request, Stonelizard determines which method implements the operation. It handles parameter extraction and decoding providing data to the method call.

Setting up Stonelizard is done by calling stonelizard.New(), providing parameters of a type that satisfies the EndPointHandler interface. The stonelizard.New() is a variadic function, allowing you to provide multiple EndPointHandler parameters. Each EndPointHandler parameter must also be defined as a struct type whose fields conforms to the following definition:

type Service struct {
   // Required field. Reserved name. Defines the root of this service, and its meta data. Tags:
   // 1. root: defines the base root path of the service
   // 2. consumes: defines default accepted input mime types
   // 3. produces: defines default provided output mime types
   // 4. allowGzip: if true and the client request compression, stonelizard will automatically compress HTTP responses
   // 5. enableCORS: if true makes stonelizard provide CORS headers when the client requests CORS INFO through the OPTIONS HTTP method
   // 6. proto: either use http or https, other protocols, like ws and wss are in my TODO list, but don't expect it soon
   // 7. access: determines the level of authentication required, but it is not handled by Stonelizard itself. Instead, it is passed to the AuthT interface to handle it.
   //    Valid values are 'none', 'auth', 'authinfo', 'verifyauth' and 'verifyauthinfo'. The 'authinfo' and 'verifyauthinfo' should work exact like 'auth' and 'verifyauth' but
   //    the information returned by the Authorize method is passed to the method that handles the operation requested. But we left the exact handle of these parameters
   //    to the object that implements the AuthT interface and so, it is possible that some implementation have very different behavior.
   root    stonelizard.Void `root:"/myservice/" consumes:"application/json" produces:"application/json" allowGzip:"true" enableCORS:"true" proto:"https" access:"verifyauthinfo"`

   // Optional fields. Reserved names. Provides service information, the tags are used by the automatic swagger.json generator.
   info    stonelizard.Void `title:"MyGreatBot" description:"This is my great service bot!" tos:"The use of this bot is regulated by my great terms of service." version:"0.1"`
   contact stonelizard.Void `contact:"John Doe" url:"http://example.com" email:"john@doe"`
   license stonelizard.Void `license:"The title of the license terms chosen" url:"http://example.com/license"`

   // Operations to create/update/delete/fetch researches (the presence of the 'method' tag tells Stonelizard that this field is an operation definition)
   // 1. The field name MUST start with a lowercase letter and the method to be called when the operation is requested MUST have the exact same
   //    name, just changing the first letter to uppercase.
   // 2. The field type defines the type of the returned data. Use stonelizard.Void when there is no data to return. The returned data does not include the HTTP status code.
   // 3. Possible tags for operation definition:
   //    3.1. method: defines the HTTP method
   //    3.2. path: define the REST path, parameter variables are defined by enclosing the variable name between braces '{' and '}'
   //    3.3. header: optional tag to define parameter variables sent through HTTP headers, multiple variable names are defined as a comma separated list
   //    3.4. query:  optional tag to define parameter variables sent through path query part, multiple variable names are defined as a comma separated list
   //    3.4. postdata: optional tag to define parameter variables sent through HTTP POST body, multiple variable names are defined as a comma separated list
   //    3.5. accepted, created, ok: optional tags to define the corresponding custom HTTP status message
   //    3.6. doc: a textual description of what the operation does
   //    3.7. tags named after the parameter variable names: a textual description of the parameters
   //    3.8. proto: optional tag it must be one of http/https/ws/wss. If either ws or wss are defined, then it defines a websocket based operation. The handler method must return an object
   //                that handles the websocket communication. Details on how to do it are explained below.
   // 4. All parameter variables are then passed to the corresponding methods. The signature of these methods must conform to which is defined by the tags
   //    4.1. The parameter order is important:
   //         4.1.1. You have to declare path parameters first and in the order they appear in the path.
   //         4.1.2. Then declare the header parameters, if there is multiple header variables, they have to be in the order that appears in the comma separated list
   //         4.1.3. Then declare the query parameters, if there is multiple query variables, they have to be in the order that appears in the comma separated list
   //         4.1.4. Then declare the post body parameters, if there is multiple body variables, they have to be in the order that appears in the comma separated list
   //         4.1.5. Lastly, you may optionally declare a parameter to receive authentication information. The type of this parameter must conform to whatever is returned
   //                by the Authorize method of the authorization system chosen by you
   newResearch int `method:"POST" path:"/research/{ResearchType}/user/{User}" header:"X-Trackid" postdata:"files" accepted:"Research registered" doc:"Use this operation to register new researchs on my great system. It returns the new research ID." X-Trackid:"A requester defined unique token to include in log messages making debugging easier." ResearchType:"The type of the research, valid values are 'x', 'y' and 'z'." User:"The user ID of the researcher." files:"Any uploaded documents related to the research."`
   dropResearch stonelizard.Void `method:"DELETE" path:"/research/{id}" header:"X-Trackid" id:"ID retornado por newResearch" ok:"Ok" X-Trackid:"ID único por request, para acompanhamento/debug via log" doc:"Removes the specified research from my great system"`
   getResearch ResearchT `method:"GET" path:"/research/{id}" header:"X-Trackid" query:"full" id:"ID retornado por newResearch" ok:"Ok" X-Trackid:"ID único por request, para acompanhamento/debug via log" doc:"Retrieves data from the specified research from my great system"`


   // Ignored by Stonelizard because they do not have a reserved name, nor the method tag, they make sense and are only useful to your application, not to Stonelizard
   someData int
   OtherData int
}

An earlier version deprecated requirement was json configuration files. Now the EndPointHandler interface just defines a GetConfig() method that returns a Shaper interface compliant data. This Shaper interface defines methods that retrieves the configuration needed by Stonelizard but left undefined in the EndPointHandler interface. This separation allows applications to choose the place to store this configuration data (the filesystem, command line parameters, environment variables, databases, whatever the application decides it is best for them).

In earlier versions, authentication was included in Stonelizard itself. Now there is an AuthT interface and an included PublicAccessT type that satisfies this interface. As the name implies, this object makes no authentication at all, allowing anyone to access the services. In the subdirectories, you will find 2 packages, certkit and certkitetcd, that provide authentication using x509 certificates. The first one, certkit, handles the certificates stored in the filesystem. The second, certkitetcd, handles certificates stored in an etcd database. Feel free to use them or develop your own authentication system.

Calling the service with a path '/swagger.json' retrieves an automatically generated swagger.json specification of the service.

Websocket handling:

When an EndPointHandler compliant type defines one or more websocket handlers (fields with the tag 'proto' with values 'ws' or 'wss'), the operation handle method must return an object of a struct type. This type may have some fields defining the behavior of the websocket. They may be operation handlers or event triggers.

Websocket operation handling:

Fields with names starting with lowercase and a struct tag 'in' are considered specifications of websocket operations. The names 'bind' and 'unbind' are reserved. There must be defined methods with the same name but with uppercase starting letters. These methods will handle the corresponding websocket operations. The method parameters must be listed in a comma separated list defined in the tag 'in'.

Websocket event triggering:

Fields of type *WSEventTrigger defines events of your websockets. They must be named with uppercase starting letters and have a struct tag 'event' defining the name of the event. Is up to your application to define the logic of the event triggering. When your application fires an event, it must trigger the event handler in the client application. To do so, just call the Send method from the corresponding *WSEventTrigger field. It returns a nil error if succesful. If the client has disconnected the error returned is ErrorEndEventTriggering and no further communication will occur. If there is no client handler for this event, the error returned is ErrorStopEventTriggering. Client handler may or may not be defined at any time using the reserved websocket operation 'bind' and 'unbind'. So, if your application receives ErrorStopEventTriggering, it means that no message was sent to the client, but the websocket is still alive and may define later a client event handler. In this case, new attempts to send event messages to the client may be succesfull and, then, a nil error will be returned.

Example:

package main

import (
   ...
   "fmt"
   "sync"
   "crypto/x509"
   "net/http"
   "mime/multipart"
   "github.com/luisfurquim/stonelizard"
   "github.com/luisfurquim/stonelizard/certkit"
   ...
)


type Service struct {
   root    stonelizard.Void `root:"/myservice/" consumes:"application/json" produces:"application/json" allowGzip:"true" enableCORS:"true" proto:"https" access:"verifyauthinfo"`

   info    stonelizard.Void `title:"MyGreatBot" description:"This is my great service bot!" tos:"The use of this bot is regulated by my great terms of service." version:"0.1"`
   contact stonelizard.Void `contact:"John Doe" url:"http://example.com" email:"john@doe"`
   license stonelizard.Void `license:"The title of the license terms chosen" url:"http://example.com/license"`

   newResearch int `method:"POST" path:"/research/{ResearchType}/user/{User}" header:"X-Trackid" postdata:"files" accepted:"Research registered" doc:"Use this operation to register new researchs on my great system. It returns the new research ID." X-Trackid:"Unique request ID, used for logging" ResearchType:"The type of the research, valid values are 'x', 'y' and 'z'." User:"The user ID of the researcher." files:"Any uploaded documents related to the research."`
   dropResearch stonelizard.Void `method:"DELETE" path:"/research/{id}" header:"X-Trackid" id:"ID retornado por newResearch" ok:"Ok" X-Trackid:"Unique request ID, used for logging" doc:"Removes the specified research from my great system"`
   getResearch ResearchT `method:"GET" path:"/research/{id}" header:"X-Trackid" id:"ID retornado por newResearch" ok:"Ok" X-Trackid:"Unique request ID, used for logging" doc:"Retrieves data from the specified research from my great system"`

   clientChat CChatT `method:"GET" path:"/chat/client" proto:"wss" header:"X-Trackid" ok:"Ok" X-Trackid:"Unique request ID, used for logging" doc:"Starts a chat with the supporting team of my great system"`
   supportChat SChatT `method:"GET" path:"/chat/support" proto:"wss" header:"X-Trackid" ok:"Ok" X-Trackid:"Unique request ID, used for logging" doc:"Waits for a client to start a chat of my great system"`

   // Let's authenticate through the certkit interface
   ck *certkit.CertKit

   someData int
   OtherData int
}

type ResearchT struct {
   A int `json:"a"`
   B string `json:"b"`
}


type SChatT struct {
   authinfo  *x509.Certificate
   send string `in:"msg" accepted:"Message received"`    // Note: the field MUST be local (using lowercase starting letter)
   WebComm *stonelizard.WSEventTrigger `event:"Message"` // Note: the field MUST be public (using uppercase starting letter)
   ch chan string
}

type CChatT struct {
   authinfo  *x509.Certificate
   send string `in:"msg" accepted:"Message received"`    // Note: the field MUST be local (using lowercase starting letter)
   WebComm *stonelizard.WSEventTrigger `event:"Message"` // Note: the field MUST be public (using uppercase starting letter)
   ch chan string
}

type RoomT struct {
   Support *SChatT
   Client  *CChatT
   w *sync.WaitGroup
}

var MyTeam map[string]RoomT = map[string]RoomT{}

// For example simplicity, we made the Service struct satisfy both the EndPointHandler and
// Shaper interfaces...
func (s Service) GetConfig() (stonelizard.Shaper, error) {
   return s, nil
}

func (s Service) PageNotFound() []byte {
   return []byte("<html><body>Page not found!</body></html>")
}

func (s Service) ListenAddress() string {
   return ":5000"
}

func (s Service) CRLListenAddress() string {
   return ":5001"
}


func (s Service) CertKit() stonelizard.AuthT {
   return s.ck
}



// The Service.NewResearch method is called when the Service.newResearch operation is requested.
// According to what was declared in the Service struct, 'ResearchType' and 'User' are parameters
// passed in the REST path, 'trackId' is a parameter passed through HTTP header, 'files' holds any
// upload file and authinfo contains the certificate provided by the authenticated client (as the
// access tag was set with the value verifyauthinfo, the certificate CA chain was already verified)
func (s *Service) NewResearch(ResearchType int, User string, trackId string, files []*multipart.FileHeader, authinfo *x509.Certificate) stonelizard.Response {

   // Do whatever your application needs to do in order to create a new research in your system,
   // for example:
   // a) store data in a persistent storage
   // b) set the newId local variable with the ID of the recently created research
   // c) authinfo may be used to log who created the research
   // d) trackId may be used to help tracking log messages from the same request for debugging

   if (some_error_occured) {
      // do some error handling
      return stonelizard.Response{
         Status: http.StatusInternalServerError, // HTTP status code to return
         Body: "My error message",
      }
   }

   return stonelizard.Response{
      // This HTTP status code to return when successful has its custom message defined by
      // the 'accepted' tag
      Status: http.StatusAccepted,
      Body: newId, // an int, as defined by the data type of the Service.newResearch field
   }
}

// The Service.DropResearch method is called when the Service.dropResearch operation is requested.
// According to what was declared in the Service struct, 'Id' is a parameter passed in the REST
// path, 'trackId' is a parameter passed through HTTP header and authinfo contains the certificate
// provided by the authenticated client (as the access tag was set with the value verifyauthinfo,
// the certificate CA chain was already verified)
func (s *Service) DropResearch(Id int, trackId string, authinfo *x509.Certificate) stonelizard.Response {

   // Do whatever your application needs to do in order to remove a research from your system,
   // for example:
   // a) remove data from a persistent storage
   // b) authinfo may be used to log who removed the research
   // c) trackId may be used to help tracking log messages from the same request for debugging

   if (some_error_occured) {
      // do some error handling
      return stonelizard.Response{
         Status: http.StatusInternalServerError, // HTTP status code to return
         Body: "My error message",
      }
   }

   return stonelizard.Response{
      Status: http.StatusOK,
   }

}


// The Service.GetResearch method is called when the Service.getResearch operation is requested.
// According to what was declared in the Service struct, 'Id' is a parameter passed in the REST
// path, 'trackId' is a parameter passed through HTTP header and, this time, no authinfo parameter
// was declared just to illustrate it is optional
func (s *Service) GetResearch(Id int, trackId string) stonelizard.Response {

   // Do whatever your application needs to do in order to retrieve a research from your system,
   // for example:
   // a) get data from a persistent storage
   // b) trackId may be used to help tracking log messages from the same request for debugging

   if (some_error_occured) {
      // do some error handling
      return stonelizard.Response{
         Status: http.StatusInternalServerError, // HTTP status code to return
         Body: "My error message",
      }
   }

   return stonelizard.Response{
      Status: http.StatusOK,
      Body: ResearchT{
         A: someRetrievedValue,
         B: anotherRetrievedValue,
      },
   }

}



// The Service.SupportChat method is called when the Service.supportChat operation is requested.
// According to what was declared in the Service struct, 'trackId' is a parameter passed through
// HTTP header and the authinfo parameter contains the certificate provided by the authenticated
// client (as the access tag was set with the value verifyauthinfo, the certificate CA chain was
// already verified)
func (s *Service) SupportChat(trackId string, authinfo *x509.Certificate) stonelizard.Response {
   var chatObj SChatT

   if (!someCheckSupportAccess(authinfo)) {
      // do some error handling
      return stonelizard.Response{
         Status: http.StatusForbidden, // HTTP status code to return
         Body: "My error message",
      }
   }


   chatObj = SChatT{
      authinfo: authinfo,
      WebComm: stonelizard.NewWSEventTrigger(),
      ch: make(chan string),
   }

   MyTeam[authinfo.Subject.CommonName] = RoomT{
      Support: &chatObj,
      w: &sync.WaitGroup{},
   }

   go func() {
      var err error
      var msg string

      defer delete(MyTeam,authinfo.Subject.CommonName)

      for {
         MyTeam[authinfo.Subject.CommonName].w.Add(1)
         MyTeam[authinfo.Subject.CommonName].w.Wait()

ClientSession:
         for {
            select {
               case msg = <-MyTeam[authinfo.Subject.CommonName].Client.ch:
                  err = chatObj.WebComm.Trigger(msg)
                  if err != nil {
                     fmt.Printf("Support Bye")
                     break ClientSession
                  }
            }
         }
      }
   }()

   return stonelizard.Response{
      Status: http.StatusOK,
      Body: &chatObj,
   }
}


func (c *SChatT) Send(msg string, authinfo *x509.Certificate) stonelizard.Response {

   MyTeam[authinfo.Subject.CommonName].Support.ch <- msg // Route the support message through its channel which is being read by the client goroutine

   return stonelizard.Response{
      Status: http.StatusOK,
      Body: "",
   }
}



// The Service.ClientChat method is called when the Service.clientChat operation is requested.
// According to what was declared in the Service struct, 'trackId' is a parameter passed through
// HTTP header and the authinfo parameter contains the certificate provided by the authenticated
// client (as the access tag was set with the value verifyauthinfo, the certificate CA chain was
// already verified)
func (s *Service) ClientChat(trackId string, authinfo *x509.Certificate) stonelizard.Response {
   var chatObj CChatT
   var schatObj RoomT
   var sname string

   if (!someCheckClientkAccess(authinfo)) {
      // do some error handling
      return stonelizard.Response{
         Status: http.StatusForbidden, // HTTP status code to return
         Body: "My error message",
      }
   }


   chatObj = CChatT{
      authinfo: authinfo,
      WebComm: stonelizard.NewWSEventTrigger(),
      ch: make(chan string),
   }

   for sname, schatObj = range MyTeam {
      if schatObj.Client == nil {
         break
      }
   }

   if schatObj.Client != nil {
      // do some error handling
      return stonelizard.Response{
         Status: http.StatusPreconditionFailed, // HTTP status code to return
         Body: "No support available",
      }
   }

   MyTeam[sname] = RoomT{
      Support: MyTeam[sname].Support,
      Client: &chatObj,
      w: MyTeam[sname].w,
   }

   go func() {
      var err error
      var msg string

      defer func() {
         MyTeam[sname] = RoomT{
            Support: MyTeam[sname].Support,
            Client: nil,
            w: MyTeam[sname].w,
         }
      }()
      MyTeam[sname].w.Done()

      for {
         select {
            case msg = <-MyTeam[sname].Support.ch:
               err = chatObj.WebComm.Trigger(msg)
               if err != nil {
                  fmt.Printf("Client Bye")
                  return
               }
         }
      }
   }()

   return stonelizard.Response{
      Status: http.StatusOK,
      Body: &chatObj,
   }
}


func (c *CChatT) Send(msg string, authinfo *x509.Certificate) stonelizard.Response {

   MyTeam[authinfo.Subject.CommonName].Client.ch <- msg // Route the client message through its channel which is being read by the support goroutine

   return stonelizard.Response{
      Status: http.StatusOK,
      Body: "",
   }
}



func MyApp() {

   .
   .
   .

   ck, err := certkit.NewFromCK("/path/to/cert/dir")
   if err != nil {
      // handle the error
   }

   err = ck.LoadUserData()
   if err != nil {
      // handle the error
   }

   ws, err := stonelizard.New(&Service{someData:6})
   if err != nil {
      // handle the error
   }

   // Code execution is hold here as the ListenAndServeTLS method enters listen mode
   err = ws.ListenAndServeTLS()
   if err != nil {
      // handle the error
   }

   .
   .
   .

}


Documentation

Overview

Stonelizard is a golang package that provides features to process HTTP requests on a Microservice architecture using REST, * Swagger and JSON technologies to communicate between services.

Example

package main

import (

"os"
"io"
"fmt"
"flag"
"net/http"
"github.com/luisfurquim/stonelizard"
"github.com/luisfurquim/goose"

)

//Set your microservice Service struct

type Service struct {
   // defines the root of this service, and its meta data.
   root bool `root:"/concurso/" consumes:"application/json" produces:"application/json" allowGzip:"true" enableCORS:"true"`

   // endpoint for create new researches
   research bool `method:"POST" path:"/research/{researchnum}/xy/{User}" postdata:"RegisterRequestT"`

   //ignored because do not have root tag or field method
   yy int
}

//Define your research struct

type ResearchRequestT struct {
   A int `json:"a"`
   B string `json:"b"`
}

//Define variable to stored the work directory path var configPath string ```

func main() {
   var err        error
   var svc        Service

   flag.StringVar(&configPath,"conf", "./config.json", "Path to JSON configuration file")
   flag.Parse()

//If your use Goose package, define the log level necessary

Goose = goose.Alert(1)
stonelizard.Goose = goose.Alert(1)

//Initialize the webservice using stonelizard.New() and ListenAndServerTLS() methods. The main flow is blocked waiting for new requests

   svc = Service{yy:6}
   ws, err := stonelizard.New(&svc)
   if err != nil {
      fmt.Printf("Error: %s\n",err)
      os.Exit(1)
   }

   err = ws.ListenAndServeTLS()
   if err != nil {
      fmt.Println(err)
   }

   os.Exit(1)
}

//Set the function that implements the endpoint service.

func (s *Service) Research(researchnum int, user string, data ResearchRequestT) stonelizard.Response {
   return stonelizard.Response{
      Status: http.StatusOK,
      Body: fmt.Sprintf("Called research with %d and %s. Data:A=%d/B=%s. Internal object data: %d\n",researchnum,user,data.A,data.B,s.yy),
   }
}

Index

Constants

View Source
const (
	AccessNone uint8 = iota
	AccessAuth
	AccessAuthInfo
	AccessVerifyAuth
	AccessVerifyAuthInfo
	AccessInfo
)
View Source
const StatusTrigEvent = 275
View Source
const StatusTrigEventDescription = "Trig Event"

Variables

View Source
var ErrorCannotWrapListener = errors.New("Cannot wrap listener")
View Source
var ErrorConversionOverflow = errors.New("Conversion overflow")
View Source
var ErrorDecodeError = errors.New("Decode error")
View Source
var ErrorDescriptionSyntax = errors.New("Syntax error on response description")
View Source
var ErrorEndEventTriggering = errors.New("End event triggering")
View Source
var ErrorFieldIsOfWSEventTriggerTypeButUnexported = errors.New("Field is of Event Trigger type, but it is not exported")
View Source
var ErrorInvalidNilParam = errors.New("Syntax error nil parameter not allowed in this context")
View Source
var ErrorInvalidParameterType = errors.New("Invalid parameter type")
View Source
var ErrorInvalidProtocol = errors.New("Invalid protocol")
View Source
var ErrorInvalidType = errors.New("Invalid type")
View Source
var ErrorMissingRequiredHTTPHeader = errors.New("Missing required HTTP header")
View Source
var ErrorMissingRequiredPostBodyField = errors.New("Error missing required post body field")
View Source
var ErrorMissingRequiredQueryField = errors.New("Error missing required query field")
View Source
var ErrorMissingWebsocketInTagSyntax = errors.New("Syntax error missing websocket 'in' tag")
View Source
var ErrorMixedProtocol = errors.New("Mixed http/https with ws/wss")
View Source
var ErrorNoRoot = errors.New("No service root specified")
View Source
var ErrorParmListSyntax = errors.New("Syntax error on parameter list")
View Source
var ErrorServiceSyntax = errors.New("Syntax error on service definition")
View Source
var ErrorStopEventTriggering = errors.New("Stop event triggering")
View Source
var ErrorStopped = errors.New("Stop signal received")
View Source
var ErrorUndefMod = errors.New("Undefined module")
View Source
var ErrorUndefPropType = errors.New("Undefined property type")
View Source
var ErrorWrongAuthorizerReturnValues = errors.New("Error wrong authorizer return values")
View Source
var ErrorWrongHandlerKind = errors.New("Wrong handler kind")
View Source
var ErrorWrongParameterCount = errors.New("Wrong parameter count")
View Source
var MapParameterEncodingError = errors.New("Map parameter encoding error")
View Source
var MaxUploadMemory int64 = 16 * 1024 * 1024
View Source
var ModType = reflect.TypeOf(Mod{})
View Source
var WrongParameterLength = errors.New("Wrong parameter length")
View Source
var WrongParameterType = errors.New("Wrong parameter type")

Functions

func GetMethodInfo

func GetMethodInfo(fld reflect.StructField, OpType reflect.Type) (bool, string, reflect.Method)

Returns if a method name, if it is pointer referenced and its reflect definition It receives the unexported field from the service definition struct and searches for a method with same name but with an uppercase first letter

func GetWebSocketEventSpec

func GetWebSocketEventSpec(field reflect.StructField, WSMethodName string, WSMethod reflect.Method) (map[string]*SwaggerWSEventT, error)

Returns a swagger definition of all the events defined by type of the struct field "field"

Types

type AuthT

type AuthT interface {
	GetTLSConfig(Access uint8) (*tls.Config, error)
	StartCRLServer(listenAddress string, listener *StoppableListener) error
	GetDNSNames() []string
	Authorize(path string, parms map[string]interface{}, RemoteAddr string, TLS *tls.ConnectionState, SavePending func(interface{}) error) (httpstat int, data interface{}, err error)
	GetServerCert() *x509.Certificate
	GetServerKey() *rsa.PrivateKey
	GetCACert() *x509.Certificate
	GetCAKey() *rsa.PrivateKey
	GetServerX509KeyPair() tls.Certificate
	GetCertPool() *x509.CertPool
	ReadCertFromReader(r io.Reader) (*x509.Certificate, []byte, error)
	ReadCertificate(fname string) (*x509.Certificate, []byte, error)
	ReadRsaPrivKeyFromReader(r io.Reader) (*rsa.PrivateKey, []byte, error)
	ReadRsaPrivKey(fname string) (*rsa.PrivateKey, []byte, error)
	ReadDecryptRsaPrivKeyFromReader(r io.Reader) (*rsa.PrivateKey, []byte, error)
	ReadDecryptRsaPrivKey(fname string) (*rsa.PrivateKey, []byte, error)
	Setup(udata map[string]interface{}) error
	LoadUserData() error
	AddUserData(usrKey string, ClientCert *x509.Certificate) error
	Trust(id string) error
	Reject(id string) error
	Drop(id string) error
	Delete(tree, id string) error
	GetPending() (map[string]interface{}, error)
	GetTrusted() (map[string]interface{}, error)
}

AuthT interface defines an authorizer function To use it put an anonymous field that satisfies the AuthT interface in the EndPointHandler provided to stonelizard.New Input (

@method: HTTP method
@path: the path part of the URL of the operation as it appears in your EndPointHandler definition
@parms: the key is the parameter name as defined in your EndPointHandler definition, the value is the one sent by the requesting client
@RemoteAddr: the remote client address
@TLS: the TLS connection information received from the client, may be nil
@SavePending: function to save pending authorization information. It receives one interface{} argument with the info to be saved for later 3rd party analysis.
              It may be just NOOP function, Authorize implementations SHOULD NOT trust that the info is really being saved.

) Output (

@httpstat: HTTP status code (used only if error is not nil)
@data: if the operation has a tag 'access' with value 'authinfo', this data is passed to the operation
       method as the last parameter (remember to declare it as interface{}). This setting is not
       added to the swagger.json generated or any other generated service description.
@err: error status (if it is not nil, the operation method is not called and the error message is sent to the client, along with the http status code)

)

type Base64Unmarshaler

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

func NewBase64Unmarshaler

func NewBase64Unmarshaler(r *http.Request) *Base64Unmarshaler

Creates a Base64 Unmarshaler

func (*Base64Unmarshaler) Decode

func (b *Base64Unmarshaler) Decode(v interface{}) error

Fetches the next value from the HTTP POST vars

type DummyUnmarshaler

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

func NewDummyUnmarshaler

func NewDummyUnmarshaler(r *http.Request) *DummyUnmarshaler

Creates a Dummy Unmarshaler

func (*DummyUnmarshaler) Decode

func (b *DummyUnmarshaler) Decode(v interface{}) error

Fetches the next value from the HTTP POST vars

type EndPointHandler

type EndPointHandler interface {
	GetConfig() (Shaper, error)
}

type ExtAuthT

type ExtAuthT interface {
	ExtAuthorize(ch chan ExtAuthorizeIn, path string, parms map[string]interface{}, resp http.ResponseWriter, req *http.Request, SavePending func(interface{}) error) (httpstat int, data interface{}, err error)
	StartExtAuthorizer(authReq chan ExtAuthorizeIn)
}

ExtAuthT interface defines an extended authorizer function. If stonelizard detects that your authorizer also satisfies this interface, then ExtAuthorize will be used INSTEAD of Authorize. Input (

@ch: channel to send authorizer request data
@path: the path part of the URL of the operation as it appears in your EndPointHandler definition
@parms: the key is the parameter name as defined in your EndPointHandler definition, the value is the one sent by the requesting client
@request: the entire http request object
@SavePending: function to save pending authorization information. It receives one interface{} argument with the info to be saved for later 3rd party analysis.
              It may be just NOOP function, Authorize implementations SHOULD NOT trust that the info is really being saved.

) Output (

@httpstat: HTTP status code (used only if error is not nil)
@data: if the operation has a tag 'access' with value 'authinfo', this data is passed to the operation
       method as the last parameter (remember to declare it as interface{}). This setting is not
       added to the swagger.json generated or any other generated service description.
@err: error status (if it is not nil, the operation method is not called and the error message is sent to the client, along with the http status code)

)

type ExtAuthorizeIn

type ExtAuthorizeIn struct {
	Path        string
	Parms       map[string]interface{}
	Resp        http.ResponseWriter
	Req         *http.Request
	SavePending func(interface{}) error
	Out         chan ExtAuthorizeOut
}

type ExtAuthorizeOut

type ExtAuthorizeOut struct {
	Stat int
	Data interface{}
	Err  error
}

type FileServerHandlerT

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

func (FileServerHandlerT) ServeHTTP

func (fs FileServerHandlerT) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HandleHttpFn

type HandleHttpFn func([]interface{}, Unmarshaler, interface{}, string, string) Response // Operation handler function, it calls the method defined by the application

type HandleWsFn

type HandleWsFn func([]interface{}, Unmarshaler) Response // Operation handler function, it calls the method defined by the application

type Marshaler

type Marshaler interface {
	Encode(v interface{}) error
}

type Mod

type Mod struct{}

type MultipartUnmarshaler

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

func NewMultipartUnmarshaler

func NewMultipartUnmarshaler(r *http.Request, fields []string) (*MultipartUnmarshaler, error)

Creates a Multipart Unmarshaler

func (*MultipartUnmarshaler) Decode

func (mp *MultipartUnmarshaler) Decode(v interface{}) error

Fetches the next value from the HTTP POST vars

func (MultipartUnmarshaler) More

func (mp MultipartUnmarshaler) More() bool

type Pki

type Pki interface {
	GenerateClientCSR(subject pkix.Name, email string) ([]byte, error)
	GenerateClient(asn1Data []byte) (*x509.Certificate, *rsa.PublicKey, error)
	NewPemCertReqFromReader(rd io.Reader) error
	NewPemCertFromMemory(buf []byte) error
	NewPemCertFromReader(rd io.Reader) error
	NewPemCertFromFile(fname string) error
	NewPemKeyFromMemory(buf []byte, password string) error
	NewPemKeyFromReader(rd io.Reader, password string) error
	NewPemKeyFromFile(fname string, password string) error
	PemKey(password string) ([]byte, error)
	PemKeyToFile(fname, password string) error
	PemCsr(der []byte, fname string) error
	NewPemCert(fname string) error
	Sign(msg string) ([]byte, error)
	Verify(msg string, signature []byte) error
	Encrypt(msg []byte) ([]byte, error)
	Decrypt(secret []byte) ([]byte, error)
	Challenge() ([]byte, []byte, error)
	QrKeyId(keyId string, challenge []byte) ([]byte, error)
	FindCertificate(keyId string) (Pki, string, error)
	Certificate() []byte
}

type PublicAccessT

type PublicAccessT struct{}

func (PublicAccessT) AddUserData

func (pa PublicAccessT) AddUserData(usrKey string, ClientCert *x509.Certificate) error

func (PublicAccessT) Authorize

func (pa PublicAccessT) Authorize(path string, parms map[string]interface{}, RemoteAddr string, TLS *tls.ConnectionState, SavePending func(interface{}) error) (httpstat int, data interface{}, err error)

func (PublicAccessT) Delete

func (pa PublicAccessT) Delete(tree, id string) error

func (PublicAccessT) Drop

func (pa PublicAccessT) Drop(id string) error

func (PublicAccessT) GetCACert

func (pa PublicAccessT) GetCACert() *x509.Certificate

func (PublicAccessT) GetCAKey

func (pa PublicAccessT) GetCAKey() *rsa.PrivateKey

func (PublicAccessT) GetCertPool

func (pa PublicAccessT) GetCertPool() *x509.CertPool

func (PublicAccessT) GetDNSNames

func (pa PublicAccessT) GetDNSNames() []string

func (PublicAccessT) GetPending

func (pa PublicAccessT) GetPending() (map[string]interface{}, error)

func (PublicAccessT) GetServerCert

func (pa PublicAccessT) GetServerCert() *x509.Certificate

func (PublicAccessT) GetServerKey

func (pa PublicAccessT) GetServerKey() *rsa.PrivateKey

func (PublicAccessT) GetServerX509KeyPair

func (pa PublicAccessT) GetServerX509KeyPair() tls.Certificate

func (PublicAccessT) GetTLSConfig

func (pa PublicAccessT) GetTLSConfig(Access uint8) (*tls.Config, error)

func (PublicAccessT) GetTrusted

func (pa PublicAccessT) GetTrusted() (map[string]interface{}, error)

func (PublicAccessT) LoadUserData

func (pa PublicAccessT) LoadUserData() error

func (PublicAccessT) ReadCertFromReader

func (pa PublicAccessT) ReadCertFromReader(r io.Reader) (*x509.Certificate, []byte, error)

func (PublicAccessT) ReadCertificate

func (pa PublicAccessT) ReadCertificate(fname string) (*x509.Certificate, []byte, error)

func (PublicAccessT) ReadDecryptRsaPrivKey

func (pa PublicAccessT) ReadDecryptRsaPrivKey(fname string) (*rsa.PrivateKey, []byte, error)

func (PublicAccessT) ReadDecryptRsaPrivKeyFromReader

func (pa PublicAccessT) ReadDecryptRsaPrivKeyFromReader(r io.Reader) (*rsa.PrivateKey, []byte, error)

func (PublicAccessT) ReadRsaPrivKey

func (pa PublicAccessT) ReadRsaPrivKey(fname string) (*rsa.PrivateKey, []byte, error)

func (PublicAccessT) ReadRsaPrivKeyFromReader

func (pa PublicAccessT) ReadRsaPrivKeyFromReader(r io.Reader) (*rsa.PrivateKey, []byte, error)

func (PublicAccessT) Reject

func (pa PublicAccessT) Reject(id string) error

func (PublicAccessT) Setup

func (pa PublicAccessT) Setup(udata map[string]interface{}) error

func (PublicAccessT) StartCRLServer

func (pa PublicAccessT) StartCRLServer(listenAddress string, listener *StoppableListener) error

func (PublicAccessT) Trust

func (pa PublicAccessT) Trust(id string) error

type ReadCloser

type ReadCloser struct {
	Rd *bytes.Reader
}

func NewReadCloser

func NewReadCloser(src []byte) ReadCloser

func (ReadCloser) Close

func (rc ReadCloser) Close() error

func (ReadCloser) Read

func (rc ReadCloser) Read(p []byte) (n int, err error)

type Response

type Response struct {
	Status int
	Header map[string]string
	Body   interface{}
}
var WebSocketResponse Response

type ResponseT

type ResponseT struct {
	Description  string
	TypeReturned interface{}
}

type ResponseWriter

type ResponseWriter interface {
	Header() http.Header
	WriteHeader(int)
}

type Service

type Service struct {
	Matcher      *regexp.Regexp
	MatchedOps   map[int]int
	Svc          []UrlNode
	Config       Shaper
	AuthRequired bool
	AllowGzip    bool
	EnableCORS   bool
	Proto        []string
	Listener     *StoppableListener
	CRLListener  *StoppableListener
	Swagger      *SwaggerT
	Access       uint8
	Authorizer   AuthT
	SavePending  func(interface{}) error
	PlainStatic  map[string]string
	SecureStatic map[string]string

	SwaggerPath string
	// contains filtered or unexported fields
}

func New

func New(svcs ...EndPointHandler) (*Service, error)

func (Service) Close

func (svc Service) Close()

Close the webservices and the listeners

func (*Service) FetchEndpointHandler

func (svc *Service) FetchEndpointHandler(proto, method, path string) (*UrlNode, []interface{}, map[string]interface{}, int)

func (*Service) ListenAndServeTLS

func (svc *Service) ListenAndServeTLS() error

Init a webserver and wait for http requests.

func (*Service) ServeHTTP

func (svc *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (Service) String

func (svc Service) String() string

Convert the UrlNode field value, from the Service struct, into a string

type ServiceWithPKI

type ServiceWithPKI struct {
	Service
	PK Pki
}

func NewWithPKI

func NewWithPKI(pk Pki, svcs ...EndPointHandler) (*ServiceWithPKI, error)

func (*ServiceWithPKI) ListenAndServeTLS

func (svc *ServiceWithPKI) ListenAndServeTLS() error

Init a webserver and wait for http requests.

func (*ServiceWithPKI) ServeHTTP

func (svc *ServiceWithPKI) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Shaper

type Shaper interface {
	PageNotFound() []byte
	ListenAddress() string
	CRLListenAddress() string
	CertKit() AuthT
}

Shaper interface has an optional method: SavePending(cert *x509.Certificate) error

type Static

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

func NewStaticEncoder

func NewStaticEncoder(w io.Writer) *Static

func (*Static) Encode

func (d *Static) Encode(v interface{}) error

type StaticBase64

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

func NewStaticBase64Encoder

func NewStaticBase64Encoder(w io.Writer) *StaticBase64

func (*StaticBase64) Encode

func (d *StaticBase64) Encode(v interface{}) error

type StonelizardG

type StonelizardG struct {
	Listener    goose.Alert
	Swagger     goose.Alert
	Initialize  goose.Alert
	OpHandle    goose.Alert
	ParseFields goose.Alert
	New         goose.Alert
	InitServe   goose.Alert
	Serve       goose.Alert
	Auth        goose.Alert
}
var Goose StonelizardG

type StoppableListener

type StoppableListener struct {
	*net.TCPListener // Wrapped listener
	// contains filtered or unexported fields
}

func NewListener

func NewListener(l net.Listener) (*StoppableListener, error)

Init the listener for the service.

func (*StoppableListener) Accept

func (sl *StoppableListener) Accept() (net.Conn, error)

http://www.hydrogen18.com/blog/stop-listening-http-server-go.html Implements a wrapper on the system accept

func (*StoppableListener) Stop

func (sl *StoppableListener) Stop()

Stop the service and releases the channel

type SwaggerContactT

type SwaggerContactT struct {
	// The identifying name of the contact person/organization.
	Name string `json:"name"`

	// The URL pointing to the contact information. MUST be in the format of a URL.
	Url string `json:"url"`

	// The email address of the contact person/organization. MUST be in the format of an email address.
	Email string `json:"email"`
}

type SwaggerEventParameterT

type SwaggerEventParameterT struct {
	Name string `json:"name"`

	// GFM syntax can be used for rich text representation
	Description *string `json:"description,omitempty"`

	// The type of the parameter / The internal type of the array.
	// Since the parameter is not located at the request body, it is limited to simple types (that is, not an object).
	// The value MUST be one of "string", "number", "integer", "boolean", "array" or "file" (Files and models are not allowed in arrays).
	// If type is "file", the consumes MUST be either "multipart/form-data" or " application/x-www-form-urlencoded" and the parameter MUST be in "formData".
	Type string `json:"type"`

	// The extending format for the previously mentioned type. See Data Type Formats for further details.
	Format string `json:"format,omitempty"`

	// If Type is "array", this must show a list of its items.
	// The list MUST NOT include duplicated parameters.
	// If type
	Items []SwaggerEventParameterT `json:"items,omitempty"`

	// Declares this operation to be deprecated.
	// Usage of the declared operation should be refrained.
	// Default value is false.
	Deprecated bool `json:"deprecated,omitempty"`

	// Determines whether this parameter is mandatory.
	// If the parameter is in "path", this property is required and its value MUST be true.
	// Otherwise, the property MAY be included and its default value is false.
	Required bool `json:"required,omitempty"`
}

type SwaggerExternalDocsT

type SwaggerExternalDocsT struct {
	// A short description of the target documentation.
	// GFM syntax can be used for rich text representation.
	Description string `json:"description,omitempty"`

	// The URL for the target documentation.
	// Value MUST be in the format of a URL.
	Url string `json:"url"`
}

type SwaggerHeaderT

type SwaggerHeaderT struct {

	// The type of the parameter / The internal type of the array.
	// Since the parameter is not located at the request body, it is limited to simple types (that is, not an object).
	// The value MUST be one of "string", "number", "integer", "boolean", "array" or "file" (Files and models are not allowed in arrays).
	// If type is "file", the consumes MUST be either "multipart/form-data" or " application/x-www-form-urlencoded" and the parameter MUST be in "formData".
	Type string `json:"type"`

	// Required if type is "array". Describes the type of items in the array.
	Items *SwaggerItemT `json:"items,omitempty"`

	// The extending format for the previously mentioned type. See Data Type Formats for further details.
	Format string `json:"format,omitempty"`

	// Declares the value of the parameter that the server will use if none is provided,
	// for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request.
	// (Note: "default" has no meaning for required parameters.)
	// See http://json-schema.org/latest/json-schema-validation.html#anchor101.
	// Unlike JSON Schema this value MUST conform to the defined type for this parameter.
	Default interface{} `json:"default,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor17.
	Maximum string `json:"maximum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor17.
	ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor21.
	Minimum string `json:"minimum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor21.
	ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor26.
	MaxLength int64 `json:"maxLength,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor29.
	MinLength int64 `json:"minLength,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor33.
	Pattern string `json:"pattern,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor42.
	MaxItems int64 `json:"maxItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor45.
	MinItems int64 `json:"minItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor49.
	UniqueItems bool `json:"uniqueItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor76.
	Enum []interface{} `json:"enum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor14.
	MultipleOf string `json:"multipleOf,omitempty"`
	// contains filtered or unexported fields
}

type SwaggerInfoT

type SwaggerInfoT struct {
	// The title of the application.
	Title string `json:"title"`

	// A short description of the application.
	// GFM syntax can be used for rich text representation.
	Description string `json:"description,omitempty"`

	// The Terms of Service for the API.
	TermsOfService string `json:"termsOfService,omitempty"`

	// The contact information for the exposed API.
	Contact SwaggerContactT `json:"contact,omitempty"`

	// The license information for the exposed API.
	License SwaggerLicenseT `json:"license,omitempty"`

	// Provides the version of the application API (not to be confused with the specification version).
	Version string `json:"version"`

	// Custom stonelizard field used to tell clients how to group client variables
	// Used to automatically generate client code
	// The first index is the module name, the second index is the property name
	XModules map[string]map[string]*SwaggerSchemaT `json:"x-modules,omitempty"`
}

type SwaggerItemT

type SwaggerItemT struct {
	// The type of the parameter / The internal type of the array.
	// Since the parameter is not located at the request body, it is limited to simple types (that is, not an object).
	// The value MUST be one of "string", "number", "integer", "boolean", "array" or "file" (Files and models are not allowed in arrays).
	// If type is "file", the consumes MUST be either "multipart/form-data" or " application/x-www-form-urlencoded" and the parameter MUST be in "formData".
	Type string `json:"type"`

	// Required if type is "array". Describes the type of items in the array.
	Items *SwaggerItemT `json:"items,omitempty"`

	// The extending format for the previously mentioned type. See Data Type Formats for further details.
	Format string `json:"format,omitempty"`

	// Declares the value of the parameter that the server will use if none is provided,
	// for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request.
	// (Note: "default" has no meaning for required parameters.)
	// See http://json-schema.org/latest/json-schema-validation.html#anchor101.
	// Unlike JSON Schema this value MUST conform to the defined type for this parameter.
	Default interface{} `json:"default,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor17.
	Maximum string `json:"maximum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor17.
	ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor21.
	Minimum string `json:"minimum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor21.
	ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor26.
	MaxLength int64 `json:"maxLength,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor29.
	MinLength int64 `json:"minLength,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor33.
	Pattern string `json:"pattern,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor42.
	MaxItems int64 `json:"maxItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor45.
	MinItems int64 `json:"minItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor49.
	UniqueItems bool `json:"uniqueItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor76.
	Enum []interface{} `json:"enum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor14.
	MultipleOf string `json:"multipleOf,omitempty"`

	// Determines the format of the array if type array is used. Possible values are:
	//   csv - comma separated values foo,bar.
	//   ssv - space separated values foo bar.
	//   tsv - tab separated values foo\tbar.
	//   pipes - pipe separated values foo|bar.
	//   multi - corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in "query" or "formData".
	//   Default value is csv.
	CollectionFormat string `json:"collectionFormat,omitempty"`

	// Custom stonelizard extension. Specifies the type of the key. Used for key-value data types
	XKeyType string `json:"x-keytype,omitempty"`

	// Custom stonelizard extension. Specifies the format of the key. Used for key-value data types
	XKeyFormat string `json:"x-keyformat,omitempty"`
}

type SwaggerLicenseT

type SwaggerLicenseT struct {
	// The license name used for the API.
	Name string `json:"name"`

	// A URL to the license used for the API. MUST be in the format of a URL.
	Url string `json:"url,omitempty"`
}

type SwaggerOperationT

type SwaggerOperationT struct {
	// A list of tags for API documentation control.
	// Tags can be used for logical grouping of operations by resources or any other qualifier.
	Tags []string `json:"tags,omitempty"`

	// A short summary of what the operation does.
	// For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.
	Summary string `json:"summary,omitempty"`

	// A verbose explanation of the operation behavior. GFM syntax can be used for rich text representation.
	Description string `json:"description,omitempty"`

	// Additional external documentation for this operation.
	ExternalDocs *SwaggerExternalDocsT `json:"externalDocs,omitempty"`

	// Unique string used to identify the operation.
	// The id MUST be unique among all operations described in the API.
	// Tools and libraries MAY use the operationId to uniquely identify an operation, therefore,
	// it is recommended to follow common programming naming conventions.
	OperationId string `json:"operationId,omitempty"`

	// A list of MIME types the operation can consume.
	// This overrides the consumes definition at the Swagger Object.
	// An empty value MAY be used to clear the global definition.
	// Value MUST be as described under Mime Types.
	Consumes []string `json:"consumes,omitempty"`

	// A list of MIME types the operation can produce.
	// This overrides the produces definition at the Swagger Object.
	// An empty value MAY be used to clear the global definition.
	// Value MUST be as described under Mime Types.
	Produces []string `json:"produces,omitempty"`

	// A list of parameters that are applicable for this operation.
	// If a parameter is already defined at the Path Item, the new definition will override it, but can never remove it.
	// The list MUST NOT include duplicated parameters.
	// A unique parameter is defined by a combination of a name and location.
	// The list can use the Reference Object to link to parameters that are defined at the Swagger Object's parameters.
	// There can be one "body" parameter at most.
	Parameters []SwaggerParameterT `json:"parameters,omitempty"`

	//  Required. The list of possible responses as they are returned from executing this operation.
	Responses map[string]SwaggerResponseT `json:"responses"`

	// The transfer protocol for the operation.
	// Values MUST be from the list: "http", "https", "ws", "wss".
	// The value overrides the Swagger Object schemes definition.
	Schemes []string `json:"schemes,omitempty"`

	// Declares this operation to be deprecated.
	// Usage of the declared operation should be refrained.
	// Default value is false.
	Deprecated bool `json:"deprecated,omitempty"`

	// A declaration of which security schemes are applied for this operation.
	// The list of values describes alternative security schemes that can be used
	// (that is, there is a logical OR between the security requirements).
	// This definition overrides any declared top-level security.
	// To remove a top-level security declaration, an empty array can be used.
	Security map[string]SwaggerSecurityT `json:"security,omitempty"`

	// Custom stonelizard extension. Specifies suboperations. Used for websocket operations.
	// The HTTP connection is upgraded to websocket connection only if the operation returns a 2XX HTTP status code.
	XWSOperations map[string]*SwaggerWSOperationT `json:"x-websocketoperations,omitempty"`

	// Custom stonelizard extension. Specifies events. Used for websocket operations.
	// Events only fire if the HTTP connection is upgraded to websocket connection and subjected to application specific
	// semantics/rules.
	XWSEvents map[string]*SwaggerWSEventT `json:"x-websocketevents,omitempty"`

	// Custom stonelizard extension. A list of websocket subprotocols the operation can consume.
	// At this moment, it only accepts the stonelizard's non-standard 'sam+json', which stands for 'JSON encoded simple array messaging'.
	XWSConsumes []string `json:"x-websocketconsumes,omitempty"`

	// Custom stonelizard extension. It doesn't affect the web service operation.
	// It is intended to provide developers a way to organize their web service client code.
	// Our suggestion is that operations belonging to the same module be accesssed using
	// the same class. But it is not mandatory.
	XModule string `json:"x-module,omitempty"`

	// Custom stonelizard extension. It doesn't affect the web service operation.
	// It is intended to provide developers a way to handle the returned data.
	// Our suggestion is to use this info to give clients a hint on WHERE to store
	// the return data
	XOutputVar string `json:"x-outputvar,omitempty"`

	// Custom stonelizard extension. It doesn't affect the web service operation.
	// It is intended to provide developers a way to handle the returned data.
	// Our suggestion is to use this info to give clients a hint on HOW to store
	// the return data
	XOutput string `json:"x-output,omitempty"`
}

type SwaggerParameterT

type SwaggerParameterT struct {
	// If in is "path", the name field MUST correspond to the associated path segment from the path field in the Paths Object.
	// See Path Templating for further information.
	// For all other cases, the name corresponds to the parameter name used based on the in property.
	// The name of the parameter. Parameter names are case sensitive.
	Name string `json:"name"`

	// The location of the parameter.
	// Possible values are "query", "header", "path", "formData" or "body".
	In string `json:"in"`

	// A brief description of the parameter.
	// This could contain examples of use.
	// GFM syntax can be used for rich text representation.
	Description string `json:"description,omitempty"`

	// Determines whether this parameter is mandatory.
	// If the parameter is in "path", this property is required and its value MUST be true.
	// Otherwise, the property MAY be included and its default value is false.
	Required bool `json:"required"`

	// The schema defining the type used for the body parameter.
	Schema *SwaggerSchemaT `json:"schema,omitempty"` // required if in=="body"

	// Sets the ability to pass empty-valued parameters.
	// This is valid only for either query or formData parameters and allows you to send a parameter with a name only or an empty value.
	// Default value is false.
	AllowEmptyValue bool `json:"allowEmptyValue,omitempty"`

	// The type of the parameter / The internal type of the array.
	// Since the parameter is not located at the request body, it is limited to simple types (that is, not an object).
	// The value MUST be one of "string", "number", "integer", "boolean", "array" or "file" (Files and models are not allowed in arrays).
	// If type is "file", the consumes MUST be either "multipart/form-data" or " application/x-www-form-urlencoded" and the parameter MUST be in "formData".
	Type string `json:"type,omitempty"`

	// The extending format for the previously mentioned type. See Data Type Formats for further details.
	Format string `json:"format,omitempty"`

	// Declares the value of the parameter that the server will use if none is provided,
	// for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request.
	// (Note: "default" has no meaning for required parameters.)
	// See http://json-schema.org/latest/json-schema-validation.html#anchor101.
	// Unlike JSON Schema this value MUST conform to the defined type for this parameter.
	Default interface{} `json:"default,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor17.
	Maximum string `json:"maximum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor17.
	ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor21.
	Minimum string `json:"minimum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor21.
	ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor26.
	MaxLength int64 `json:"maxLength,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor29.
	MinLength int64 `json:"minLength,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor33.
	Pattern string `json:"pattern,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor42.
	MaxItems int64 `json:"maxItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor45.
	MinItems int64 `json:"minItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor49.
	UniqueItems bool `json:"uniqueItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor76.
	Enum []interface{} `json:"enum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor14.
	MultipleOf string `json:"multipleOf,omitempty"`

	// Determines the format of the array if type array is used. Possible values are:
	//   csv - comma separated values foo,bar.
	//   ssv - space separated values foo bar.
	//   tsv - tab separated values foo\tbar.
	//   pipes - pipe separated values foo|bar.
	//   multi - corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in "query" or "formData".
	//   Default value is csv.
	CollectionFormat string `json:"collectionFormat,omitempty"`

	// Custom stonelizard extension. Currently it only accepts cskv (comma separated key-values: k1:v1,...,kn:vn)
	XCollectionFormat string `json:"x-collectionFormat,omitempty"`

	// Custom stonelizard extension. Specifies the type of the key. Used for key-value data types
	XKeyType string `json:"x-keytype,omitempty"`

	// Custom stonelizard extension. Specifies the format of the key. Used for key-value data types
	XKeyFormat string `json:"x-keyformat,omitempty"`
}

func GetSwaggerType

func GetSwaggerType(parm reflect.Type) (*SwaggerParameterT, error)

Returns a swagger definition of the type received Scalar types are just a simple type string and maybe a format specification Nils are nils :P Pointers get de-referenced and then we recurse Aggregated types (array/slice, map and struct) needs more burocracy, but they all end up recursing until we reach the scalar types

func ParseFieldList

func ParseFieldList(listEncoding string, parmcountIn int, fld reflect.StructField, method reflect.Method, methodName string, swaggerParametersIn []SwaggerParameterT) (list []string, parmcount int, pt reflect.Type, swaggerParameters []SwaggerParameterT, err error)

Consider this example tag: `query:"field1,field2" field1:"This is the first parameter for this operation"` Searches for a listEncoding ('query' in this example) and returns a swagger list of parameters with 2 parameters ("field1" and "field2") the parameter "field1" will have a documentation based on the text provided by the tag "field1", the parameter "field2" will have no documentation

type SwaggerPathT

type SwaggerPathT map[string]*SwaggerOperationT

type SwaggerResponseT

type SwaggerResponseT struct {
	// A short description of the response. GFM syntax can be used for rich text representation.
	Description string `json:"description"`

	// A definition of the response structure.
	// It can be a primitive, an array or an object.
	// If this field does not exist, it means no content is returned as part of the response.
	// As an extension to the Schema Object, its root type value may also be "file".
	// This SHOULD be accompanied by a relevant produces mime-type.
	Schema *SwaggerSchemaT `json:"schema,omitempty"`

	// A list of headers that are sent with the response.
	Headers map[string]SwaggerHeaderT `json:"headers,omitempty"`

	// An example of the response message.
	Examples map[string]interface{} `json:"examples,omitempty"`
}

type SwaggerSchemaT

type SwaggerSchemaT struct {
	Title string `json:"title,omitempty"`

	// GFM syntax can be used for rich text representation
	Description *string `json:"description,omitempty"`

	// The type of the parameter / The internal type of the array.
	// Since the parameter is not located at the request body, it is limited to simple types (that is, not an object).
	// The value MUST be one of "string", "number", "integer", "boolean", "array" or "file" (Files and models are not allowed in arrays).
	// If type is "file", the consumes MUST be either "multipart/form-data" or " application/x-www-form-urlencoded" and the parameter MUST be in "formData".
	Type string `json:"type"`

	// Required if type is "array". Describes the type of items in the array.
	//   Items            *SwaggerItemT   `json:"items,omitempty"`
	Items *SwaggerSchemaT `json:"items,omitempty"`

	// The extending format for the previously mentioned type. See Data Type Formats for further details.
	Format string `json:"format,omitempty"`

	// Declares the value of the parameter that the server will use if none is provided,
	// for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request.
	// (Note: "default" has no meaning for required parameters.)
	// See http://json-schema.org/latest/json-schema-validation.html#anchor101.
	// Unlike JSON Schema this value MUST conform to the defined type for this parameter.
	Default interface{} `json:"default,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor17.
	Maximum string `json:"maximum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor17.
	ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor21.
	Minimum string `json:"minimum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor21.
	ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor26.
	MaxLength int64 `json:"maxLength,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor29.
	MinLength int64 `json:"minLength,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor33.
	Pattern string `json:"pattern,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor42.
	MaxItems int64 `json:"maxItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor45.
	MinItems int64 `json:"minItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor49.
	UniqueItems bool `json:"uniqueItems,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor76.
	Enum []interface{} `json:"enum,omitempty"`

	// See http://json-schema.org/latest/json-schema-validation.html#anchor14.
	MultipleOf string `json:"multipleOf,omitempty"`

	// The value of this keyword MUST be an integer. This integer MUST be greater than, or equal to, 0.
	// An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.
	MaxProperties uint64 `json:"maxProperties,omitempty"`

	// The value of this keyword MUST be an integer. This integer MUST be greater than, or equal to, 0.
	// An object instance is valid against "maxProperties" if its number of properties is more than, or equal to, the value of this keyword.
	MinProperties uint64 `json:"minProperties,omitempty"`

	// Lists which of the objetct properties are mandatory.
	Required []string `json:"required,omitempty"`

	// This keyword's value MUST be an array. This array MUST have at least one element.
	// Elements of the array MUST be objects. Each object MUST be a valid Swagger JSON Schema.
	// An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value.
	AllOf []*SwaggerSchemaT `json:"allOf,omitempty"`

	Properties map[string]SwaggerSchemaT `json:"properties,omitempty"`

	// The value of "additionalProperties" MUST be a boolean or an object.
	// If it is an object, it MUST also be a valid JSON Schema.
	// SL: Always a schema...
	AdditionalProperties *SwaggerSchemaT `json:"additionalProperties,omitempty"`

	// Adds support for polymorphism.
	// The discriminator is the schema property name that is used to differentiate between other schema that inherit this schema.
	// The property name used MUST be defined at this schema and it MUST be in the required property list.
	// When used, the value MUST be the name of this schema or any schema that inherits it.
	Discriminator string `json:"discriminator,omitempty"`

	// Relevant only for Schema "properties" definitions.
	// Declares the property as "read only".
	// This means that it MAY be sent as part of a response but MUST NOT be sent as part of the request.
	// Properties marked as readOnly being true SHOULD NOT be in the required list of the defined schema.
	// Default value is false.
	ReadOnly bool `json:"readOnly,omitempty"`

	// This MAY be used only on properties schemas.
	// It has no effect on root schemas.
	// Adds Additional metadata to describe the XML representation format of this property.
	Xml *SwaggerXmlT `json:"xml,omitempty"`

	// External Documentation Object Additional external documentation for this schema.
	ExternalDocs *SwaggerExternalDocsT `json:"externalDocs,omitempty"`

	// A free-form property to include a an example of an instance for this schema.
	Example interface{} `json:"example,omitempty"`

	// Custom stonelizard extension. Currently it only accepts cskv (comma separated key-values: k1:v1,...,kn:vn)
	XCollectionFormat string `json:"x-collectionFormat,omitempty"`

	// Custom stonelizard extension. Specifies the type of the key. Used for key-value data types
	XKeyType string `json:"x-keytype,omitempty"`

	// Custom stonelizard extension. Specifies the format of the key. Used for key-value data types
	XKeyFormat string `json:"x-keyformat,omitempty"`
}

type SwaggerSecDefsT

type SwaggerSecDefsT struct {
	// Validity: Any
	// Required. The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
	Type string `json:"type"`

	// Validity: Any
	// A short description for security scheme.
	Description string `json:"description,omitempty"`

	// Validity:  apiKey   Required.
	// The name of the header or query parameter to be used.
	Name string `json:"name"`

	// Validity:  apiKey   Required
	// The location of the API key. Valid values are "query" or "header".
	In string `json:"in"`

	// Validity:  oauth2   Required.
	// The flow used by the OAuth2 security scheme. Valid values are "implicit", "password", "application" or "accessCode".
	Flow string `json:"flow"`

	// Validity:  oauth2 ("implicit", "accessCode")   Required.
	// The authorization URL to be used for this flow. This SHOULD be in the form of a URL.
	AuthorizationUrl string `json:"authorizationUrl"`

	// Validity:  oauth2 ("password", "application", "accessCode")   Required.
	// The token URL to be used for this flow. This SHOULD be in the form of a URL.
	TokenUrl string `json:"tokenUrl"`

	// Validity:  oauth2   Required.
	// The available scopes for the OAuth2 security scheme.
	// Maps between a name of a scope to a short description of it (as the value of the property).
	Scopes map[string]string `json:"scopes"`
}

type SwaggerSecurityT

type SwaggerSecurityT []string

type SwaggerT

type SwaggerT struct {
	// Required. Specifies the Swagger Specification version being used.
	// It can be used by the Swagger UI and other clients to interpret the API listing.
	// The value MUST be "2.0".
	Version string `json:"swagger"`

	// Required. Provides metadata about the API.
	// The metadata can be used by the clients if needed.
	Info SwaggerInfoT `json:"info"`

	// The host (name or ip) serving the API.
	// This MUST be the host only and does not include the scheme nor sub-paths.
	// It MAY include a port. If the host is not included, the host serving the documentation is to be used (including the port).
	// The host does not support path templating.
	Host string `json:"host,omitempty"`

	// The base path on which the API is served, which is relative to the host.
	// If it is not included, the API is served directly under the host.
	// The value MUST start with a leading slash (/).
	// The basePath does not support path templating.
	BasePath string `json:"basePath,omitempty"`

	// The transfer protocol of the API.
	// Values MUST be from the list: "http", "https", "ws", "wss".
	// If the schemes is not included, the default scheme to be used is the one used to access the Swagger definition itself.
	// SL: only "https" supported right now.
	Schemes []string `json:"schemes,omitempty"`

	// A list of MIME types the APIs can consume.
	// This is global to all APIs but can be overridden on specific API calls.
	// Value MUST be as described under Mime Types.
	Consumes []string `json:"consumes,omitempty"`

	// A list of MIME types the APIs can produce.
	// This is global to all APIs but can be overridden on specific API calls.
	// Value MUST be as described under Mime Types.
	Produces []string `json:"produces,omitempty"`

	// The available paths and operations for the API.
	Paths map[string]SwaggerPathT `json:"paths"`

	// An object to hold data types produced and consumed by operations.
	Definitions map[string]SwaggerSchemaT `json:"definitions,omitempty"`

	// An object to hold parameters that can be used across operations.
	// This property does not define global parameters for all operations.
	Parameters []SwaggerParameterT `json:"parameters,omitempty"`

	// An object to hold responses that can be used across operations.
	// This property does not define global responses for all operations.
	Responses map[string]SwaggerResponseT `json:"responses,omitempty"`

	// Security scheme definitions that can be used across the specification.
	SecurityDefinitions map[string]SwaggerSecDefsT `json:"securityDefinitions,omitempty"`

	// A declaration of which security schemes are applied for the API as a whole.
	// The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements).
	// Individual operations can override this definition.
	Security []SwaggerSecurityT `json:"security,omitempty"`

	// A list of tags used by the specification with additional metadata.
	// The order of the tags can be used to reflect on their order by the parsing tools.
	// Not all tags that are used by the Operation Object must be declared.
	// The tags that are not declared may be organized randomly or based on the tools' logic.
	// Each tag name in the list MUST be unique.
	Tags []SwaggerTagT `json:"tags,omitempty"`

	// Additional external documentation.
	ExternalDocs *SwaggerExternalDocsT `json:"externalDocs,omitempty"`
}

All the fields comments are copied from swagger specification at http://swagger.io/specification/ Stonelizard is not entirely compliant with the specification right now. We tried to add notes (preceded by the 'SL:' notation) pointing the differences, but it is possible that we have missed some details here or there.

type SwaggerTagT

type SwaggerTagT struct {
	// Required. The name of the tag.
	Name string `json:"name"`

	// A short description for the tag. GFM syntax can be used for rich text representation.
	Description string `json:"description,omitempty"`

	// Additional external documentation for this tag.
	ExternalDocs *SwaggerExternalDocsT `json:"externalDocs,omitempty"`
}

type SwaggerWSEventT

type SwaggerWSEventT struct {
	// A list of tags for API documentation control.
	// Tags can be used for logical grouping of operations by resources or any other qualifier.
	Tags []string `json:"tags,omitempty"`

	// A short summary of when the event fires.
	// For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.
	Summary string `json:"summary,omitempty"`

	// A verbose explanation of the event behavior. GFM syntax can be used for rich text representation.
	Description string `json:"description,omitempty"`

	// Additional external documentation for this event.
	ExternalDocs *SwaggerExternalDocsT `json:"externalDocs,omitempty"`

	// Required. Unique string used to identify the websocket event.
	// The operation id combined with the event id MUST be unique among
	// all operations+events described in the API. Tools and libraries MAY use the
	// operationId/eventId combination to uniquely identify a websocket
	// event, therefore, it is recommended to follow common programming naming
	// conventions.
	EventId string `json:"eventId"`

	// A list of parameters that are applicable for this websocket event.
	// The list MUST NOT include duplicated parameters.
	Parameters []SwaggerEventParameterT `json:"parameters,omitempty"`

	// Declares this event to be deprecated.
	// Usage of the declared event should be refrained.
	// Default value is false.
	Deprecated bool `json:"deprecated,omitempty"`

	// A declaration of which security schemes are applied for this operation.
	// The list of values describes alternative security schemes that can be used
	// (that is, there is a logical OR between the security requirements).
	// This definition overrides any declared top-level security.
	// To remove a top-level security declaration, an empty array can be used.
	Security map[string]SwaggerSecurityT `json:"security,omitempty"`
}

type SwaggerWSOperationT

type SwaggerWSOperationT struct {
	// A list of tags for API documentation control.
	// Tags can be used for logical grouping of operations by resources or any other qualifier.
	Tags []string `json:"tags,omitempty"`

	// A short summary of what the operation does.
	// For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.
	Summary string `json:"summary,omitempty"`

	// A verbose explanation of the operation behavior. GFM syntax can be used for rich text representation.
	Description string `json:"description,omitempty"`

	// Additional external documentation for this operation.
	ExternalDocs *SwaggerExternalDocsT `json:"externalDocs,omitempty"`

	// Required. Unique string used to identify the websocket suboperation.
	// The operation id combined with the suboperation id MUST be unique among
	// all operations described in the API. Tools and libraries MAY use the
	// operationId/suboperationId combination to uniquely identify a websocket
	// suboperation, therefore, it is recommended to follow common programming naming
	// conventions.
	SuboperationId string `json:"suboperationId"`

	// A list of parameters that are applicable for this websocket suboperation.
	// The list MUST NOT include duplicated parameters.
	Parameters []SwaggerParameterT `json:"parameters,omitempty"`

	// Required. The list of possible responses as they are returned from executing this operation.
	Responses map[string]SwaggerResponseT `json:"responses"`

	// Declares this operation to be deprecated.
	// Usage of the declared operation should be refrained.
	// Default value is false.
	Deprecated bool `json:"deprecated,omitempty"`

	// A declaration of which security schemes are applied for this operation.
	// The list of values describes alternative security schemes that can be used
	// (that is, there is a logical OR between the security requirements).
	// This definition overrides any declared top-level security.
	// To remove a top-level security declaration, an empty array can be used.
	Security map[string]SwaggerSecurityT `json:"security,omitempty"`
}

func GetWebSocketSpec

func GetWebSocketSpec(field reflect.StructField, WSMethodName string, WSMethod reflect.Method) (*SwaggerWSOperationT, error)

Returns de websocket swagger specification

type SwaggerXmlT

type SwaggerXmlT struct {
	// Replaces the name of the element/attribute used for the described schema property.
	// When defined within the Items Object (items), it will affect the name of the individual XML elements within the list.
	// When defined alongside type being array (outside the items), it will affect the wrapping element and only if wrapped is true.
	// If wrapped is false, it will be ignored.
	Name string `json:"name,omitempty"`

	// The URL of the namespace definition. Value SHOULD be in the form of a URL.
	Namespace string `json:"namespace,omitempty"`

	// The prefix to be used for the name.
	Prefix string `json:"prefix,omitempty"`

	// Declares whether the property definition translates to an attribute instead of an element.
	// Default value is false.
	Attribute bool `json:"attribute,omitempty"`

	// MAY be used only for an array definition.
	// Signifies whether the array is wrapped (for example, <books><book/><book/></books>) or unwrapped (<book/><book/>).
	// Default value is false. The definition takes effect only when defined alongside type being array (outside the items).
	Wrapped bool `json:"wrapped,omitempty"`
}

type Unmarshaler

type Unmarshaler interface {
	Decode(v interface{}) error
}

type UrlNode

type UrlNode struct {
	Path string // The URL path with input parameters

	Proto []string // Valid protocols: http, https, ws, wss

	Headers           []string // List of HTTP header parameters required by the operation for input
	Query             []string // List of query parameters required by the operation for input
	Body              []string // List of HTTP body parameters required by the operation for input
	ParmNames         []string // Complete list of parameter names (from path, headers, query and body)
	Handle            HandleHttpFn
	WSocketOperations *strtree.Node // If this.Proto contains ws | wss, then store here the suboperations defined by the methods of the type returned by the main handlers
	WSocketEvents     *strtree.Node // If this.Proto contains ws | wss, then store here the events defined by the event fields of the type returned by the main handlers
	// contains filtered or unexported fields
}

func (UrlNode) String

func (u UrlNode) String() string

Convert the Handle field value, from UrlNode struct, into a Go-syntax string (method signature)

type Void

type Void struct{}

type WSEventTrigger

type WSEventTrigger struct {
	EventData chan interface{}
	Status    bool
}

func NewWSEventTrigger

func NewWSEventTrigger() *WSEventTrigger

Initializes a websocket event trigger

func (*WSEventTrigger) Trigger

func (wset *WSEventTrigger) Trigger(data ...interface{}) (err error)

Call this method from your websocket to trigger an event all parameters data will be sent through the websocket to the client. The data parameters MUST be compliant (length and types) to what you defined in the StructTag for your particular event.

type WSocketEventRegistry

type WSocketEventRegistry []*websocket.Conn

type WSocketOperation

type WSocketOperation struct {
	ParmNames []string       // List of parameter names
	CallByRef bool           // Flags methods whoose receiver is a pointer
	Method    reflect.Method // Method to handle the operation
}

Directories

Path Synopsis
certkit module

Jump to

Keyboard shortcuts

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