nets

package
v0.4.26 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package nets 网络相关.

包括 支持json和protobuf的简单web服务,

Index

Examples

Constants

View Source
const (
	ContentType = "Content-Type"
)

Variables

This section is empty.

Functions

func GetIP added in v0.2.15

func GetIP() []byte

GetIP 获取IP地址.

Example
package main

import (
	"fmt"

	"github.com/xuender/oils/nets"
)

func main() {
	ip := nets.GetIP()
	fmt.Println(ip)
}
Output:

func IsJSON

func IsJSON(req *http.Request) bool

func WithLogging

func WithLogging(handler http.Handler) http.Handler

func WithNotFound

func WithNotFound(path string, handler http.Handler) http.Handler

func WithRecover

func WithRecover(handler Handler) http.Handler

func Write

func Write(writer io.Writer, msg proto.Message, isJSON bool)

Types

type Dirs added in v0.2.13

type Dirs []string

func (Dirs) Close added in v0.2.13

func (p Dirs) Close() error

func (Dirs) IsDir added in v0.2.13

func (p Dirs) IsDir() bool

func (Dirs) ModTime added in v0.2.13

func (p Dirs) ModTime() time.Time

func (Dirs) Mode added in v0.2.13

func (p Dirs) Mode() fs.FileMode

func (Dirs) Name added in v0.2.13

func (p Dirs) Name() string

func (Dirs) Open added in v0.2.13

func (p Dirs) Open(name string) (http.File, error)

func (Dirs) Read added in v0.2.13

func (p Dirs) Read(data []byte) (int, error)

func (Dirs) Readdir added in v0.2.13

func (p Dirs) Readdir(count int) ([]fs.FileInfo, error)

func (Dirs) Seek added in v0.2.13

func (p Dirs) Seek(offset int64, whence int) (int64, error)

func (Dirs) Size added in v0.2.13

func (p Dirs) Size() int64

func (Dirs) Stat added in v0.2.13

func (p Dirs) Stat() (fs.FileInfo, error)

func (Dirs) Sys added in v0.2.13

func (p Dirs) Sys() any

type Handler

type Handler interface {
	GET() []byte
	POST(data []byte, isJSON bool) proto.Message
	Recover(any) proto.Message
}

type Service

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

func NewService

func NewService(handler Handler) *Service

func (*Service) Handler

func (p *Service) Handler(path string) http.Handler

Jump to

Keyboard shortcuts

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