server

package module
v0.0.0-...-fa0533c Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2014 License: BSD-2-Clause Imports: 14 Imported by: 0

README

server

HTTP Static Server module base on Martini.

基于 Martini 的 HTTP 静态文件服务器模块, 不包含路由. 只支持以下功能:

  • 最基础的命令行参数
  • os.Getenv 获取命令行参数
  • 支持 TOML 配置文件
  • 安全关闭机制
  • 静态文件输出, 预压缩
  • 预置 i18n 接口

虽然只是最基本的功能, 但确实是一个完整的架构.

Usage

Simple:

package main

import "github.com/typepress/server"

func main() {
	server.Simple()
}

Run:

package main

import (
	"github.com/typepress/core"
	"github.com/typepress/server"
)

func main() {

	// *martini.Martini, martini.Router
	m, r := core.Martini()

	// stopSignal for stop server safe, Usage:
	// core.FireSignal(stopSignal)

	stopSignal := server.StopSignal()

	// something

	err := server.Run(m, r)
	println(err)
}

License

BSD-2-Clause

Documentation

Overview

TypePress server module.

Index

Constants

View Source
const Version = "v0.0.0-alpha"

Semantic Versioning. See also - http://semver.org/

Variables

View Source
var (
	AppVersion string
)

Functions

func LoadConfig

func LoadConfig()
  LoadConfig 调入基本配置从:
	- 命令行参数.
	- 环境变量, 通过 os.Setenv(core.SessionName+"_laddr") 形式进行设置.
	- TOML 格式配置文件.

func NewDoor

func NewDoor(hh http.Handler, notify chan bool, io bool) *doorHandler
  NewDoor 返回可安全关闭的 http.Handler.

  参数:

  hh  是要包裹的 http.Handler, 安全关闭后通知 notify 通道.
  io  指示具体访问通道的方向:
	- true  表示 input,  c.notify <- true
	- false 表示 output, <-c.notify

func Run

func Run(m *martini.Martini, r martini.Router) error

func Simple

func Simple() error

func StopSignal

func StopSignal() os.Signal

返回一个停止信号, 可用 core.FireSignal 触发信号通知服务器安全关闭.

Types

This section is empty.

Jump to

Keyboard shortcuts

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