Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Logger is the global logger for the server. Logger = log.New(os.Stdout, "", 0) )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { HTTPAddr string `json:"http_addr"` HTTPPort int `json:"http_port"` IdleTimeout int `json:"idle_timeout"` ReadTimeout int `json:"read_timeout"` WriteTimeout int `json:"write_timeout"` LogFilename string `json:"log_filename"` }
Config holds info required to configure a togo.server.
func LoadJSONFile ¶
LoadJSONFile attempts to read a specified JSON file by provided filename. It then attempts to unmarshal the JSON data into a Config type object. It returns a populated Config or any errors it encountered during the JSON file load and parse.
type Resource ¶
type Resource struct { Path string Method string Handler http.HandlerFunc }
Resource holds info required for configuring endpoints and resources for the server.
func (Resource) SanitizedPath ¶
SanitizedPath trims forward slash characters from the provided string prefix and Path of the resource. Returns the sanitized path string.
type Service ¶
type Service interface { Prefix() string Middleware(http.HandlerFunc) http.HandlerFunc Resources() []Resource }
Service is the basic interface that defines what to expect from any service.
type Togo ¶
type Togo struct {
// contains filtered or unexported fields
}
Togo is a microservice application server. To use, you create an instance, passing a name and a configuration. You then register services to your instance, and then call `Run()`. Example:
t := togo.Init("my-togo", togo.LoadJSONFile("config.json")) t.Register(myservice.New()) if err := t.Run(); err != nil { fmt.Fprintf(os.Stderr, "%v", err) os.Exit(1) }