http

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 9 Imported by: 3

Documentation

Overview

Simple http web server support apis and static files both. GoFrame used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func App

func App(host string, port int, apiv string, apis *APIS, apig *APIG)

Create a http server, with default routes[/(public),/api,/swagger], apis is a map of api interfaces,

func Download

func Download(url string, filepath string, descPrefix ...string) (int64, error)

descPrefix used for progressbar, format is like "[cyan]1/3[reset]", "Downloading..."

func Get

func Get(url string, timeout ...int) (string, error)

func MiddlewareDefault

func MiddlewareDefault(r *ghttp.Request)

Default Middleware

func Post

func Post(url string, data interface{}, contentType string, timeout ...int) (string, error)

Types

type APIG

type APIG map[string]ResourceHandle

type APIS

type APIS map[string]interface{}

type DefaultHandlerResponse

type DefaultHandlerResponse struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

type Meta

type Meta = g.Meta

type MiddlewareFn

type MiddlewareFn func(r *Request)

Self-defined Middleware Intermediate processing of the interface

type Request

type Request = ghttp.Request

type Resource

type Resource interface{}

type ResourceHandle

type ResourceHandle struct {
	MiddlewareCallback MiddlewareFn
	// Pointer of Resource struct
	Res Resource
}

Jump to

Keyboard shortcuts

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