Documentation ¶
Overview ¶
Go Web Framework.
Hello world example:
package main import ( "github.com/ivpusic/neo" ) func main() { app := neo.App() app.Get("/", func(this *neo.Ctx) { this.Res.Text("I am Neo Programmer", 200) }) app.Start() }
Here you can find Neo API documentation. For tutorials visit project website. http://178.62.122.135/
Index ¶
- Constants
- func Assert(condition bool, status int, message []byte)
- func AssertNil(obj interface{}, status int, message []byte)
- func AssertNotNil(obj interface{}, status int, message []byte)
- type AppModeSettings
- type Application
- func (a *Application) Region() *Region
- func (a *Application) Serve(url string, path string)
- func (a *Application) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (a *Application) SetConfigFile(confFile string)
- func (a *Application) Start()
- func (a *Application) Templates(templates ...string)
- type ApplicationSettings
- type Conf
- type Cookie
- type Ctx
- type CtxData
- type HotReload
- type LoggerSettings
- type NeoAssertError
- type NeoSettings
- type Next
- type Region
- func (m Region) Delete(path string, fn handler) *Route
- func (m Region) Get(path string, fn handler) *Route
- func (m Region) Head(path string, fn handler) *Route
- func (m Region) Options(path string, fn handler) *Route
- func (m Region) Post(path string, fn handler) *Route
- func (m Region) Put(path string, fn handler) *Route
- func (m Region) Use(fn middleware)
- type Request
- type Response
- type Route
- type Static
- type UrlParam
Constants ¶
const ( GET = "GET" POST = "POST" PUT = "PUT" DELETE = "DELETE" OPTIONS = "OPTIONS" HEAD = "HEAD" )
supported HTTP methods
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
Asserting some condition. If assertion fails, code bellow assert won't execute, and Neo will return to client provided “status“ and “message“.
func AssertNil ¶
Same as assert, but instead of passing some boolean condition as first argument, here we are passing object, and checking if object is nil.
func AssertNotNil ¶
Same as assert, but instead of passing some boolean condition as first argument, here we are passing object, and checking if object is not nil.
Types ¶
type AppModeSettings ¶
type AppModeSettings struct {
Addr string
}
type Application ¶
type Application struct { // Event emmiter/receiver ebus.EBus // Application Configuration parameters Conf *Conf // Application logger instance Logger *golog.Logger // contains filtered or unexported fields }
Representing Neo application instance
func (*Application) Region ¶
func (a *Application) Region() *Region
Making new region instance. You can create multiple regions.
func (*Application) Serve ¶
func (a *Application) Serve(url string, path string)
Defining paths for serving static files. For example if we say: a.Serve("/some", "./mypath") then if we require “/some/js/file.js“, Neo will look for file at “./mypath/js/file.js“.
func (*Application) ServeHTTP ¶
func (a *Application) ServeHTTP(w http.ResponseWriter, req *http.Request)
Handler interface “ServeHTTP“ implementation. Method will accept all incomming HTTP requests, and pass requests to appropriate handlers if they are defined.
func (*Application) SetConfigFile ¶
func (a *Application) SetConfigFile(confFile string)
SetConfigFile lets you optionally set custom config file path.
func (*Application) Start ¶
func (a *Application) Start()
Starting application instance. This will run application on port defined by configuration.
func (*Application) Templates ¶
func (a *Application) Templates(templates ...string)
If you are planning to return templates from Neo route handler, then you have to compile them. This method will accept list of paths/files and compile them. You can use also paths with wildcards (example: /some/path/*).
type ApplicationSettings ¶
type ApplicationSettings struct { Addr string Logger LoggerSettings }
type Conf ¶
type Conf struct { Hotreload HotReload App ApplicationSettings Neo NeoSettings }
type Ctx ¶
type Ctx struct { ebus.EBus // Wrapped http.Request object. Req *Request // Object with utility methods for writing responses to http.ResponseWriter Res *Response // Context data map Data CtxData }
Representing context for this request.
type CtxData ¶
type CtxData map[string]interface{}
Map which will hold your Request contextual data.
type LoggerSettings ¶
type NeoAssertError ¶
type NeoAssertError struct {
// contains filtered or unexported fields
}
Type which will be passed as argument of “panic“ if Neo assertion fails.
type NeoSettings ¶
type NeoSettings struct {
Logger LoggerSettings
}
type Region ¶
type Region struct {
// contains filtered or unexported fields
}
type Request ¶
Wrapped http.Request. It contains utility methods for dealing with content of incomming http.Request instance.
type Response ¶
type Response struct { Status int Writer http.ResponseWriter Cookie Cookie Header http.Header // contains filtered or unexported fields }
Server response representation.
func (*Response) Json ¶
Will produce JSON string representation of passed object, and send it to client