Watch 1 Star 0 Fork 0

哔u哔u / goBottleGoApache-2.0

Join us
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
a super simple golang HTTP Toolkit spread retract

Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

goBottle

a super simple golang HTTP Toolkit

Apache License 2.0

install

  1. go get gitee.com/huanggefan/goBottle

  2. use go mod

hello world

package main

import (
	"fmt"
	"gitee.com/huanggefan/goBottle"
	"log"
	"net/http"
)

// goBottle func
func hello (ctx *goBottle.HttpContext) {
	fmt.Println(ctx.Request.Method, ctx.Request.URL)
	_, _ = fmt.Fprint(ctx.ResponseWriter, "hello world")
}

func main() { 
    // new Http Handler
    mux := goBottle.New()

    // register route
    mux.GET("/a", hello)

    // new http server
    serve := http.Server{
	    Addr:              "127.0.0.1:8080",
	    Handler:           mux,
    }

    // run
    log.Println("http://127.0.0.1:8080/")
    if err := serve.ListenAndServe(); err != nil {
	    log.Fatalln(err)
    }
}

examples

you can find examples at ./examples directory

Comments ( 0 )

Sign in for post a comment

Go
1
https://gitee.com/huanggefan/goBottle.git
git@gitee.com:huanggefan/goBottle.git
huanggefan
goBottle
goBottle
master

Help Search

220309 7019f5b6 1899542 220318 4015cbb9 1899542