rapid

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

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

Go to latest
Published: May 18, 2017 License: MIT Imports: 9 Imported by: 1

README

Build Status Go Report Card codecov GoDoc

Rapid is a lightweight micro-framework built for quickly developing webservers and rest apis.

With a syntax and routing system inspired by Express.js, Flask & Laravel, developing end points is easy to pick up.


Install Rapid

go get github.com/Kiricon/Rapid


Hello World

package main

import (
	"github.com/Kiricon/Rapid"
)

func main() {

    app := rapid.App()

    app.Get("/", func(c rapid.Connection) {
        c.Send("Hello World")
    })


    app.Listen(3000)
}

Features

  • Routing
  • Url parameters
  • Templating
  • Static file serving
  • Zero Dependencies (Only standard Library calls)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	R      *http.Request
	W      http.ResponseWriter
	Params map[string]string
	JSON   interface{}
	// contains filtered or unexported fields
}

Connection - struct for handling http request and write

func (*Connection) NotFound

func (c *Connection) NotFound()

NotFound - Return 404 message to user

func (*Connection) Redirect

func (c *Connection) Redirect(path string)

Redirect - Redirect a request to another rest end point

func (*Connection) Render

func (c *Connection) Render(path string, object interface{})

Render - Render HTML view with templating Templating uses standard library templating

func (*Connection) Send

func (c *Connection) Send(message string)

Send - Return plain text string back to http request

func (*Connection) SendJSON

func (c *Connection) SendJSON(object interface{})

SendJSON - Send json string back to client

func (*Connection) View

func (c *Connection) View(path string)

View - Render HTML view without templating

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server - Individual instance of a rapid server

func App

func App() Server

App - Create an instance of a rapid server

func (*Server) Delete

func (s *Server) Delete(path string, handler routeHandler)

Delete - Create http DELETE rest endpoint

func (*Server) Get

func (s *Server) Get(path string, handler routeHandler)

Get - Create http GET rest endpoint

func (*Server) Listen

func (s *Server) Listen(port int)

Listen - Start webserver on specified port Returns the instance of the http server currently runing. You can use this instance to shutdown the server if need be.

func (*Server) ListenAndWait

func (s *Server) ListenAndWait(port int, wait bool)

ListenAndWait - Gives user option of waiting for server or not

func (*Server) NotFoundMessage

func (s *Server) NotFoundMessage(message string)

NotFoundMessage - Set the 404 message that users will see

func (*Server) NotFoundPage

func (s *Server) NotFoundPage(path string)

NotFoundPage - Set page to use for not found message

func (*Server) Post

func (s *Server) Post(path string, handler routeHandler)

Post - Create http POST rest endpoint

func (*Server) Put

func (s *Server) Put(path string, handler routeHandler)

Put - Create http PUT rest endpoint

func (*Server) Route

func (s *Server) Route(path string, handler routeHandler)

Route - Create a route for your webserver

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown - Gracefully shut down the server and unblock the server thread.

func (*Server) StaticFolder

func (s *Server) StaticFolder(path string, dir string)

StaticFolder - Specify application public/static folder

func (*Server) ViewFolder

func (s *Server) ViewFolder(path string)

ViewFolder - Specifiy root folder to look for views/html files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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