bix

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

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

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 7 Imported by: 0

README

BixGo

Go Report Card GoDoc Issues GitHub pull requests

Modern Golang Web Framework (the under construction!!!)

Installation

To install BixGo use the go get command:
go get github.com/MuratSs/BixGo

Then you can add BixGo binary to PATH environment variable in your ~/.bashrc or ~/.bash_profile file:
export PATH=$PATH:<your_main_gopath>/bin
If you already have BixGo installed, updating BixGo is simple:
go get -u github.com/MuratSs/BixGo

Contributing

  1. Fork it
  2. Create a feature branch (git checkout -b new-feature)
  3. Commit changes (git commit -am "Added new feature xyz")
  4. Push the branch (git push origin new-feature)
  5. Create a new pull request.

Documentation

Overview

Example

Examples that describe how to implement route handlers that accept query parameters and path variables.

// Sample search handler.
search := func(writer http.ResponseWriter, request *http.Request) {
	params := GetParams(request.Context())
	fmt.Printf("Search for: \"%s\"\n", params["s"])
	writer.WriteHeader(200)
}

// Sample get resource handler.
getBookByIsbn := func(writer http.ResponseWriter, request *http.Request) {
	params := GetParams(request.Context())
	fmt.Printf("Get book with ISBN = %s\n", params["isbn"])
	writer.WriteHeader(200)
}

// build the router.
router := NewRouter().
	AddRoute("GET", "/search", search).
	AddRoute("GET", "/book/{isbn}", getBookByIsbn)

// Start the server.
server := httptest.NewServer(router)
defer server.Close()

http.Get(server.URL + "/search?s=stuff+to+search+for")
http.Get(server.URL + "/book/978-0316371247")
Output:

Search for: "stuff to search for"
Get book with ISBN = 978-0316371247

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicStart

func BasicStart()

func GetParams

func GetParams(ctx context.Context) map[string]string

Retrieves query string parameters from the request context.

func HelloServer

func HelloServer(w http.ResponseWriter, r *http.Request)

func HttpFileHandler

func HttpFileHandler(response http.ResponseWriter, request *http.Request)

func Startbix

func Startbix()

BASIC DOCS SERVE FUNC

Types

type Handler

type Handler func(http.ResponseWriter, *http.Request)

Prototype for the handler function.

type Router

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

Stores routes added by the application.

func NewRouter

func NewRouter() *Router

NewRouter initializes a new HTTP request httprouter.

func (*Router) AddRoute

func (router *Router) AddRoute(verb string, path string, handler Handler) *Router

Adds a new route with a handler function. The router structure is also returned to allow chaining.

func (*Router) ServeHTTP

func (router *Router) ServeHTTP(writer http.ResponseWriter, request *http.Request)

Default global request handler that matches the incoming request with a registered handler.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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