hime

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2017 License: MIT Imports: 21 Imported by: 6

README

Hime

Go Report Card GoDoc

Hime is a Go Web Framework.

Why Framework

I like net/http but... there are many duplicated code when working on multiple projects, and no standard. Framework creates a standard which make developers to follow.

Why Another Framework

There're many Go framework out there. But I want a framework that works with any net/http compatible libraries seamlessly.

For example, you can choose any router, any middlewares, or handlers that work with standard library.

Other framework don't allow this. They have built-in router, framework-specific middlewares.

Core focus

  • Add standard to code
  • Compatible with any net/http compatible router
  • Compatible with http.Handler without code change
  • Compatible with net/http middlewares without code change
  • Use standard html/template for view
  • Built-in core functions for build web server
  • Reduce developer bug

What this framework DO NOT focus

  • Speed
  • One framework do everything

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(h Handler) http.Handler

Wrap wraps hime handler with http.Handler

Types

type App

type App interface {
	http.Handler

	// Builder
	TemplateDir(path string) App
	TemplateRoot(name string) App
	TemplateFuncs(funcs ...template.FuncMap) App
	Component(filename ...string) App
	Template(name string, filename ...string) App
	BeforeRender(m middleware.Middleware) App
	Minify() App
	Handler(factory HandlerFactory) App
	Route(name, path string) App
	GracefulShutdown() App
	ShutdownTimeout(d time.Duration) App
	ListenAndServe(addr string) error

	GetRoute(name string) string
}

App is the hime app

func New

func New() App

New creates new app

type Context

type Context interface {
	context.Context

	Request() *http.Request
	ResponseWriter() http.ResponseWriter

	Status(code int) Context

	// Results
	Redirect(url string) Result
	SafeRedirect(url string) Result
	RedirectTo(name string) Result
	Error(error string) Result
	View(name string, data interface{}) Result
	JSON(data interface{}) Result
	String(format string, a ...interface{}) Result
	CopyFrom(src io.Reader) Result
	Bytes(b []byte) Result
	Handle(h http.Handler) Result
}

Context is the hime context

type Handler

type Handler func(Context) Result

Handler is the hime handler

type HandlerFactory

type HandlerFactory func(App) http.Handler

HandlerFactory is the function for create router

type Result

type Result interface {
	Response(w http.ResponseWriter, r *http.Request)
}

Result is the handler result

type ResultFunc

type ResultFunc func(w http.ResponseWriter, r *http.Request)

ResultFunc is the result function

func (ResultFunc) Response

func (f ResultFunc) Response(w http.ResponseWriter, r *http.Request)

Response implements Result interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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