Categorygithub.com/go-ego/ego
modulepackage
0.0.0-20200410162016-263eb77d34e2
Repository: https://github.com/go-ego/ego.git
Documentation: pkg.go.dev

# README

Ego

Build Status codecov CircleCI Status Go Report Card GoDoc Release Join the chat at https://gitter.im/go-ego/ego

Ego is a full-stack web framework written in Go, lightweight and efficient front-end component solutions, based on gin. The front-end is compiled, does not affect the back-end.

This is a work in progress.

简体中文

Contents

Docs

Requirements:

Go Version ≥1.7

Installation:

go get github.com/go-ego/ego

Update:

go get -u github.com/go-ego/ego  

Build-tools

go get -u github.com/go-ego/re 

re new

To create a new Ego web application

$ re new my-webapp

re run

To run the application we just created, you can navigate to the application folder and execute:

$ cd my-webapp && re run

Examples:

Router

package main

import (
	"github.com/go-ego/ego"
)

func main() {

	router := ego.Classic()
	ego.UseRenders()

	router.GlobHTML("views/html/*")

	parArr := [5]int{1, 2, 3, 4, 5}
	router.Ego("/head/", "head/head.html", ego.Map{
		"head":   "Test to load the HTML template",
		"parArr": parArr,
	})

	router.Run(":3100")
}

icon.vgo

// pkg icon

<div class="icon">
	<i class="iconfont {vclass}" {node}></i>
	<p>{prpo}</p>
</div>

<style>

.header-left{
	float:left;
}

.header-right{
	float:right;
}

.iconfont {
  position: relative;
  font-size:24px
}
</style>

head.vgo

import (
	"icons"
	icon "icons/icon.vgo"
	)

<div class="head">
	<div>ego:{{.head}}</div>

	<icon>
		vclass={icon-share-to}
		node={ id="slot1"}
		prpo={node---1}
	</icon>

	<div>
		{{range .parArr}}
	        <p>arr::: {{.}}</p>
		{{end}}
	</div>

</div>

Renderings:

TestRestful


package main

import (
	"github.com/go-ego/ego"
)

const httpUrl string = "http://127.0.0.1:3000"

func main() {

  router := ego.Classic()

  router.Static("/js", "./views/js")
  router.Static("/src", "./views/src")
  router.GlobHTML("views/html/*")

  strUrl := httpUrl + "/test/hlist"
  paramMap := ego.Map{
    "lon":  "10.1010101",
    "lat":  "20.202020",
    "type": "1",
  }
  router.TestHtml(strUrl, paramMap) // http url, http parameter, args (optional parameters): The default is "data".

  router.Run(":3100")
}

Renderings:

More instructions

Plans

  • Compression and merge css/js
  • CSS Preprocessing
  • Try supports MVVM and vdom
  • Update web framework

Donate

Contributing

License

Ego is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

API http api.
BasicAuth returns a Basic HTTP Authorization middleware.
BasicAuthForRealm returns a Basic HTTP Authorization middleware.
No description provided by the author
No description provided by the author
Classic returns an Engine instance with the Logger and Recovery middleware already attached.
CreateTestContext create a Context test help returns a fresh engine and context for testing purposes.
Default returns an Engine instance with the Logger and Recovery middleware already attached.
No description provided by the author
DisableConsoleColor disables color output in the console.
No description provided by the author
ErrorLogger returns a handlerfunc for any error type.
ErrorLoggerT returns a handlerfunc for a given error type.
Get http get.
GetVersion get the ego version.
Go404 configurates http.HandlerFunc which is called when no matching route is found.
IsDebugging returns true if the framework is running in debug mode.
No description provided by the author
No description provided by the author
Logger instances a Logger middleware that will write the logs to ego.DefaultWriter.
LoggerWithWriter instance a Logger middleware with the specified writter buffer.
No description provided by the author
New returns a new blank Engine instance without any middleware attached.
Post
Post http post, params is url.Values type.
PostFile post file.
Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.
SetMode set ego mode.
No description provided by the author
No description provided by the author
WrapF is a helper function for wrapping http.HandlerFunc Returns a Gin middleware.
WrapH is a helper function for wrapping http.Handler Returns a Gin middleware.

# Constants

AuthUserKey is the cookie name for user credential in basic auth.
No description provided by the author
No description provided by the author
No description provided by the author
EnvEgoMode set the mode env.
Content-Type MIME of the most common data formats.
Content-Type MIME of the most common data formats.
Content-Type MIME of the most common data formats.
Content-Type MIME of the most common data formats.
Content-Type MIME of the most common data formats.
Content-Type MIME of the most common data formats.
Content-Type MIME of the most common data formats.
No description provided by the author
No description provided by the author
Version is Framework's version.

# Variables

No description provided by the author
DefaultWriter is the default io.Writer used the Ego for debug output and middleware output like Logger() or Recovery().
No description provided by the author

# Structs

Context is the most important part of ego.
Engine is the framework's instance, it contains the muxer, middleware and configuration settings.
No description provided by the author
Param is a single URL parameter, consisting of a key and a value.
No description provided by the author
RouterGroup is used internally to configure router, a RouterGroup is associated with a prefix and an array of handlers (middleware).

# Interfaces

No description provided by the author
No description provided by the author
ResponseWriter ...

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
Map is a shortcut for map[string]interface{} type H map[string]interface{}.
Params is a Param-slice, as returned by the router.
No description provided by the author