xhttp

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: GPL-2.0, GPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

---------------------------------------------------------------------//

GNU GENERAL PUBLIC LICENSE                       //
   Version 2, June 1991                          //
                                                 //

Copyright (C) Wells Hsu, wellshsu@outlook.com, All rights reserved. // Everyone is permitted to copy and distribute verbatim copies // of this license document, but changing it is not allowed. //

SEE LICENSE.md FOR MORE DETAILS.                   //

---------------------------------------------------------------------// Package xhttp: 支持建立Http、Https两种短链接服务,应用层开箱即用.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	http.Server        // 基类服务
	Key         string // 服务密钥
	Cert        string // 服务证书
}

Http服务

func NewServer

func NewServer() *Server

新建Http服务

func (*Server) SetAddr

func (this *Server) SetAddr(addr string) *Server

设置连接地址和端口(:PORT)

func (*Server) SetHandler

func (this *Server) SetHandler(handler http.HandlerFunc) *Server

设置请求回调

handler: 回调函数

func (*Server) SetHttps

func (this *Server) SetHttps(key string, cert string) *Server

设置Https密钥和证书(若未设置则启动http监听) 生成密钥:openssl genrsa -out server.key 2048 生成证书:openssl req -new -x509 -key server.key -out server.crt -days 365 参数说明:Common Name = localhost/domain/ip

func (*Server) Start

func (this *Server) Start() *Server

启动服务

func (*Server) Stop

func (this *Server) Stop()

停止服务

Jump to

Keyboard shortcuts

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