nuri

package module
v0.0.0-...-a2c7f68 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: MIT Imports: 2 Imported by: 0

README

nuri

Nuri is web library on golang

Version

v1.0.0

Example

print "Hello, World!" with status code, 200

nuri.GET("/", func(c nuri.Context) (int, string) {
  return 200, "Hello, World!"
})

print "<Hello, World!>"

nuri.GET("/", func(c nuri.Context) (int, string) {
  return c.ToText(200, "<Hello, World!>")
})

print HTML

nuri.GET("/", func(c nuri.Context) (int, string) {
  return 200, "<h1>Hello, World!</h1>"
})

How to run

nuri.Run(":5000")

It runs on localhost:5000

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MethodGET GET
	MethodGET methodType = "GET"
	// MethodHEAD HEAD
	MethodHEAD methodType = "HEAD"
	// MethodPOST POST
	MethodPOST methodType = "POST"
	// MethodPUT PUT
	MethodPUT methodType = "PUT"
	// MethodDELETE DELETE
	MethodDELETE methodType = "DELETE"
	// MethodCONNECT CONNECT
	MethodCONNECT methodType = "CONNECT"
	// MethodOPTIONS OPTIONS
	MethodOPTIONS methodType = "OPTIONS"
	// MethodTRACE TRACE
	MethodTRACE methodType = "TRACE"
	// MethodPATCH PATCH
	MethodPATCH methodType = "PATCH"
)

methods

Functions

func CONNECT

func CONNECT(path string, h HandlerFuncType)

CONNECT handles a page when the method is CONNECT

func DELETE

func DELETE(path string, h HandlerFuncType)

DELETE handles a page when the method is DELETE

func GET

func GET(path string, h HandlerFuncType)

GET handles a page when the method is GET

func HEAD(path string, h HandlerFuncType)

HEAD handles a page when the method is HEAD

func OPTIONS

func OPTIONS(path string, h HandlerFuncType)

OPTIONS handles a page when the method is OPTIONS

func PATCH

func PATCH(path string, h HandlerFuncType)

PATCH handles a page when the method is PATCH

func POST

func POST(path string, h HandlerFuncType)

POST handles a page when the method is POST

func PUT

func PUT(path string, h HandlerFuncType)

PUT handles a page when the method is PUT

func Run

func Run(addr string)

Run runs pages that you make

func Set404

func Set404(h HandlerFuncType)

Set404 shows a page that shows what you programmed when the path is not declared

func SetNotFoundHandler

func SetNotFoundHandler(h HandlerFuncType)

SetNotFoundHandler shows a page that shows what you programmed when the path is not declared It the same with Set404 function.

func TRACE

func TRACE(path string, h HandlerFuncType)

TRACE handles a page when the method is TRACE

Types

type Context

type Context struct {
	// Request is the same with *http.Request
	Request *http.Request
	// ToText makes html to text/plain
	ToText func(int, string) (int, string)
	// SetHeader sets the header value corresponding to the key
	SetHeader func(string, string)
	// GetFormValue gets the form value corresponding to the key
	GetFormValue func(string) string
	// GetFormFile gets the form file corresponding to the key
	GetFormFile func(string) (multipart.File, *multipart.FileHeader, error)
}

Context context

type HandlerFuncType

type HandlerFuncType func(c Context) (int, string)

Jump to

Keyboard shortcuts

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