Skip to content

Lqlsoftware/Gopcap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.