core

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: MIT Imports: 12 Imported by: 8

README

Aeridya

Single domain webserver/CMS written and extendable using Golang

Description

Aeridya extends the built-in HTTP functionality of Golang to deliver Web Pages where the logic is written in Golang. The final render of the webpage uses Golang's Templating System to deliver static pages. This provides you with the flexibility of HTML/CSS/JavaScript in an easy package, and the speed to do server side logic in Go. The final application is recommended to run via a reverse proxy; specifically NGINX. More documentation on this will be written once the application is further along.

Aeridya applications should consist of a Theme which routes incomming connections to the functions that it containts. A Theme is recommended to contain Pages, which a Page consists of a set of instructions for each of the main HTTP Requests, ie. "GET", "PUT", "POST", "DELETE", "OPTIONS", "HEAD".

See "basic" for an example application. You may also want to see "theme.go" on how the basic theme is implemented.

Using Aeridya

To use Aeridya in your application, you must have a configuration file setup. "See basic/conf" for the necessary basic configuration.

The following must be set in the configuration file:

## Configuration for basic site using Aeridya
## A "#" denotes a comment in the configuration
## A ";" denotes the beginning of a section
## The Aeridya Section is required by the Aeridya Core
;Aeridya

# Log location 
## NOTE: use stdout to get term output
Log = stdout

# Port to listen on
Port = 8000

# Domain name
Domain = domain.com

# HTTPS Setting.
## NOTE:  Aeridya itself does not handle HTTPS, and HTTPS 
## is only availble when used via a reverse proxy
## This setting will set the internal URL for routing
HTTPS = false

# Development Mode
## NOTE:  In production, it is recommended to disable
Development = true

# Workers
## Sets allowed connections able to do work 
Workers = 10

Documentation

Index

Constants

View Source
const (
	//NAME is the name of the librar
	NAME = "Aeridya"
	//MAJORVER is the Major Version
	MAJORVER = "1"
	//MINORVER is the Minor Version
	MINORVER = "0"
	//RELEASEVER is the Release Version
	RELEASEVER = "2"
	//DESC is a description of the library
	DESC = "Server and CMS"
)

Variables

View Source
var (
	Port        string
	Domain      string
	FullDomain  string
	Development bool
	HTTPS       bool

	Serve func(*Response)
	Error func(*Response)

	UseSSL bool

	AutoSSL          bool
	AutoSSLDirectory string

	HTTPSPort string
	SSLCert   string
	SSLKey    string
)

Functions

func AddHandler

func AddHandler(priority int, handle func(http.Handler) http.Handler)

AddHandler adds an http Handler to the map, requires a priority set

func Create

func Create(conf string) error

Create loads the configuration file and sets Aeridya up

func DeleteHandler

func DeleteHandler(priority int)

DeleteHandler removes an httpHandler based on the priority set

func GetHandler

func GetHandler() map[int]func(http.Handler) http.Handler

GetHandler returns the current handler map

func Info

func Info() string

Info returns a formatted string of Version and the Description

func Run

func Run() error

Run starts the server, begins Aeridya

func Version

func Version() string

Version returns a formatted string of the name/version number

Types

type Response

type Response struct {
	// W reference to the http.ResponseWriter
	W http.ResponseWriter
	// R reference to the http.Request
	R *http.Request
	// Status of the current request
	Status int
	// Err contains the connection error if applicable
	Err error
	// Data holds data as the request is passed in Aeridya
	Data interface{}
}

Response is a convenience struct containing data for Aeridya to parse the connection for a user

func (*Response) Bad

func (r *Response) Bad(status int, msg string)

Bad takes a status and returns connection as an error // Recommended: 400+, 500+

func (*Response) Error

func (r *Response) Error(msg string)

error creates an error object from a string, sets it in response

func (*Response) GetData added in v1.0.1

func (r *Response) GetData(key string) (string, bool)

GetData retrieves the data from the POST request Takes a key and returns the data, boolean to check if found converts the []string from the response to a string

func (*Response) GetDataValues added in v1.0.2

func (r *Response) GetDataValues(keys ...string) ([]string, bool)

func (*Response) Good

func (r *Response) Good(status int)

Good takes a status and completes the connection // Recommend: 200 status code

func (*Response) Redirect

func (r *Response) Redirect(status int, url string)

Redirect changes the URL using the status provided // Recommended status: 301(permenant), 302(temporary), 303(See Other)

func (*Response) Return added in v1.0.2

func (r *Response) Return(status int, data []byte)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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