scaffold

package module
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 16 Imported by: 0

README

Scaffold

Go version GoDoc license LoC codecov

Scaffold is a Golang framework that includes everything needed to create database-backed API applications.

Requirements

Frameworks and libraries

Scaffold comes with:

  • gorilla/mux, a powerful HTTP router and URL matcher for building Go web servers
  • swaggo/swag, automatically generate RESTful API documentation with Swagger
  • go-orm/gorm, the fantastic ORM library for Golang, aims to be developer friendly

Getting Started

  1. Install Scaffold at the command prompt:
sudo curl -L "https://github.com/nanernunes/scaffold/releases/latest/download/scaffold-$(uname -s)-$(uname -m)" -o /usr/local/bin/scaffold
sudo chmod +x /usr/local/bin/scaffold
  1. At the command prompt, create a new Scaffold application: (where myapp is the application name)
scaffold new myapp
  1. Change directory to myapp and start the web server:
cd myapp
make dev
  1. Go to http://localhost:4000 and you'll see the Swagger documentation.

  2. Under http://localhost:4000/index there is the default Index (controller/view) home page.

  3. Follow the guidelines to start developing your application:

Contributing

Contributions to Scaffold are welcome and appreciated. If you would like to contribute, please open an issue or submit a pull request.

License

Scaffold is licensed under the MIT License. See the LICENSE file for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextAdapter added in v0.2.0

func ContextAdapter(handleFunc func(context *Context)) func(w http.ResponseWriter, r *http.Request)

Types

type Context added in v0.2.0

type Context struct {
	Request  *http.Request
	Response http.ResponseWriter
}

func NewContext added in v0.2.0

func NewContext(w http.ResponseWriter, r *http.Request) (context *Context)

func (*Context) Header added in v0.2.0

func (c *Context) Header(header string) string

func (*Context) Headers added in v0.2.0

func (c *Context) Headers() map[string]string

func (*Context) Param added in v0.2.0

func (c *Context) Param(param string) (content string)

func (*Context) Params added in v0.2.0

func (c *Context) Params() map[string]string

func (*Context) Render added in v0.2.0

func (c *Context) Render(statusCode int, src interface{})

func (*Context) RenderHTML added in v0.2.0

func (c *Context) RenderHTML(statusCode int, html string)

func (*Context) RenderText added in v0.2.0

func (c *Context) RenderText(statusCode int, text string)

func (*Context) UnmarshalBody added in v0.2.0

func (c *Context) UnmarshalBody(dest interface{}) error

func (*Context) UseCORS added in v0.2.0

func (c *Context) UseCORS()

type Controller added in v0.2.0

type Controller interface {
	Index(*Context)
	Show(*Context)
	Create(*Context)
	Update(*Context)
	Delete(*Context)
}

type ResponseError

type ResponseError struct {
	// Message with an error
	Error            string `json:"error"`
	ErrorDescription string `json:"error_description"`

} //	@name	Error

type Router added in v0.2.0

type Router struct {
	Internal *mux.Router
}

func NewRouter added in v0.2.0

func NewRouter(router *mux.Router) *Router

func (*Router) CONNECT added in v0.2.0

func (r *Router) CONNECT(route string, callback func(context *Context))

func (*Router) DELETE added in v0.2.0

func (r *Router) DELETE(route string, callback func(context *Context))

func (*Router) GET added in v0.2.0

func (r *Router) GET(route string, callback func(context *Context))

func (*Router) HEAD added in v0.2.0

func (r *Router) HEAD(route string, callback func(context *Context))

func (*Router) OPTIONS added in v0.2.0

func (r *Router) OPTIONS(route string, callback func(context *Context))

func (*Router) PATCH added in v0.2.0

func (r *Router) PATCH(route string, callback func(context *Context))

func (*Router) POST added in v0.2.0

func (r *Router) POST(route string, callback func(context *Context))

func (*Router) PUT added in v0.2.0

func (r *Router) PUT(route string, callback func(context *Context))

func (*Router) Resource added in v0.2.0

func (r *Router) Resource(route string, controller Controller)

func (*Router) ServeHTTP added in v0.2.0

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Router) TRACE added in v0.2.0

func (r *Router) TRACE(route string, callback func(context *Context))

type Template added in v0.2.0

type Template struct {
	ProjectName    *helpers.Name
	ResourceName   *helpers.Name
	ResourceFields map[*helpers.Name]string
	Imports        []string
}

func NewTemplate added in v0.2.0

func NewTemplate(project string) *Template

func (*Template) AddMVC added in v0.2.0

func (t *Template) AddMVC(name string, fields map[*helpers.Name]string)

func (*Template) CreateFile added in v0.2.0

func (t *Template) CreateFile(src string, dst string, any interface{})

func (*Template) CreateFiles added in v0.2.0

func (t *Template) CreateFiles(files map[string]string)

func (*Template) Skel added in v0.2.0

func (t *Template) Skel()

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

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