Skip to content

Latest commit

 

History

History
77 lines (68 loc) · 1.44 KB

README.md

File metadata and controls

77 lines (68 loc) · 1.44 KB

Gopcap

A Multithreading HTTP Web framework.

Quick start

# assume the following codes in main.go file
$ cat main.go
package main

import (
    "github.com/Lqlsoftware/gopcap"
    "github.com/Lqlsoftware/gopcap/http"
)

func main() {
    gopcap.Bind("/", http.GET, handler)
    gopcap.Start(80) // serve on 80 port(http)
}

func handler(req *http.HttpRequest, rep *http.HttpResponse) {
    rep.Write("Hello World!\n")
}
# run main.go and server will start.
$ go run main.go

Using

  • Download and install it:
$ go get github.com/Lqlsoftware/Gopcap
  • Import package in your code:
import "github.com/Lqlsoftware/gopcap"
  • Write a handle function like:
func handler(req *http.HttpRequest, rep *http.HttpResponse) {
    rep.Write("Hello World!\n")
}
  • Bind your handle function with an URL in your main function:
gopcap.Bind("/", http.GET, handler)
  • Start server with port:
gopcap.Start(80)
  • Run your project and enjoy!

  • Put static html file in root folder (generate automaticly).

Php7

  • Download go-php library github.com/deuill/go-php
$ go get github.com/deuill/go-php
  • Download Gopcap with tags php:
$ go get -tags php github.com/Lqlsoftware/Gopcap

or build Gopcap with tags php:

$ go build -tags php github.com/Lqlsoftware/Gopcap
  • Enable Gopcap php in your main function:
gopcap.SetUsePhp()
  • .php file will be excuted automaticaly.