app

package
v0.0.0-...-cf5c4a9 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package app defines the Kisipar web server application.

Example
package main

import (
	"log"
	"os"
	"path/filepath"

	"github.com/biztos/kisipar"
	"github.com/biztos/kisipar/app"
)

func main() {

	// For testing purposes, let's not really launch the servers:
	kisipar.LAUNCH_SERVERS = false

	// ...and let's not do tricky logging:
	log.SetFlags(0)
	log.SetOutput(os.Stdout)

	// We conveniently have some test sites on disk we can use for this:
	path1 := filepath.Join("test_data", "site_1")
	path2 := filepath.Join("test_data", "site_2")

	// Imagining this usage:
	os.Args = []string{
		"kisipar", // arg zero: the app
		path1,     // arg one: the first site to launch
		path2,     // arg two: the second site to launch
	}

	// This, our simple launcher, will launch those:
	err := app.Run("Kisipar Example", "1.0.0", "kisipar-example")
	if err != nil {
		log.Fatal(err)
	}

}
Output:

Test Site One: listening on port 8081.
Test Site Two: listening on port 8082.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(name, version, binary string) error

Run runs the application with the standard options and the provided name, version, and binary name; and the default usage spec from Usage. The first error encountered is returned.

func main() {
    if err := kisipar.Run("Foobar Thingy","1.2.3","foobar"); err != nil
       log.Fatal(err)
    }
    log.Println("DONE.")
}

func Usage

func Usage(name, version, binary string) string

Usage returns the standard DocOpt-style usage specification with the given name as the proper app name with version.

Types

type Options

type Options struct {
	SitePaths []string
}

Options represents the standard set of command-line options, which are parsed according to the usage specification provided to GetOpts.

func GetOpts

func GetOpts(heading, usage string) *Options

GetOpts processes arguments, exiting if the result is not ready to serve. The usage argument must be a DocOpt-style specification (and help text), and the heading argument must be the application name including version, e.g. "Kisipar 1.0.0" or "Naval Fate 2.0".

Jump to

Keyboard shortcuts

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