Skip to content

cit965/cithttp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ctp Web Framework

Ctp is a web framework written in Go. Now , the purpose for this project is only to learn how to write a go http framework !

Example

package main

import (
	"github.com/cit965/ctp"
	"time"
)

func main() {
	r := ctp.Default()
	r.GET("/foo", ctp.Recovery(), ctp.Log(), FooControllerHandler)
	g := r.Group("/boo")
	g.Use(ctp.Log())
	{
		g.GET("/hello", FooControllerHandler)
		g.GET("/xx/:id", FooControllerHandler)
	}
	r.Run(":8000")

}

func FooControllerHandler(c *ctp.Context) {
	time.Sleep(time.Second * 3)
	c.Json(200, "success")
}

use middle

there are two ways to add middleware

  1. add to group
  2. add to single router

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages