gopcap

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2018 License: GPL-3.0 Imports: 10 Imported by: 2

README

Gopcap

A Multithreading HTTP web server based on pcap TCP layer.

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).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(Url string, method http.HttpMethod, handler func(*http.HttpRequest, *http.HttpResponse))

绑定URL

func DeBind

func DeBind(Url string, method http.HttpMethod)

解绑URL

func SetUsePhp added in v0.4.0

func SetUsePhp()

func Start

func Start(port layers.TCPPort)

启动服务器

Types

This section is empty.

Directories

Path Synopsis
default build with out php
default build with out php

Jump to

Keyboard shortcuts

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