删除老的文件
Showing
20 changed files
with
0 additions
and
326 deletions
.DS_Store
0 → 100644
No preview for this file type
beego/beego.go
deleted
100644 → 0
| 1 | package beego | ||
| 2 | |||
| 3 | import { | ||
| 4 | "net" | ||
| 5 | "net/http" | ||
| 6 | "net/http/fcgi" | ||
| 7 | "log" | ||
| 8 | "strconv" | ||
| 9 | "./core" | ||
| 10 | } | ||
| 11 | type C struct { | ||
| 12 | core.Content | ||
| 13 | } | ||
| 14 | |||
| 15 | type M struct{ | ||
| 16 | core.Model | ||
| 17 | } | ||
| 18 | |||
| 19 | type D struct{ | ||
| 20 | core.Config | ||
| 21 | } | ||
| 22 | |||
| 23 | type U struct{ | ||
| 24 | core.URL | ||
| 25 | } | ||
| 26 | |||
| 27 | type A struct{ | ||
| 28 | core.Controller | ||
| 29 | } | ||
| 30 | |||
| 31 | type V struct{ | ||
| 32 | core.View | ||
| 33 | } | ||
| 34 | |||
| 35 | type BeegoApp struct{ | ||
| 36 | Port int | ||
| 37 | } | ||
| 38 | |||
| 39 | func (app *BeegoApp) BeeListen(port int) { | ||
| 40 | app.Port = port | ||
| 41 | err := http.ListenAndServe(":"+strconv.Itoa(app.Port), nil) | ||
| 42 | if err != nil { | ||
| 43 | log.Fatal("ListenAndServe: ", err) | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | func (app *BeegoApp) BeeListenFcgi(port int) { | ||
| 48 | app.Port = port | ||
| 49 | l, err := net.Listen("tcp", "127.0.0.1:"+strconv.Itoa(port)) | ||
| 50 | if err != nil { | ||
| 51 | log.Fatal("ListenAndServe: ", err) | ||
| 52 | } | ||
| 53 | fcgi.Serve(l, app.Handler) | ||
| 54 | } | ||
| 55 | |||
| 56 | func Run() { | ||
| 57 | rootPath, _ := os.Getwd() | ||
| 58 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
beego/cache/memcache.go
deleted
100644 → 0
File mode changed
beego/core/acl.go
deleted
100644 → 0
File mode changed
beego/core/controller.go
deleted
100644 → 0
| 1 | package beego | ||
| 2 | |||
| 3 | // Interface for controller types that handle requests | ||
| 4 | type Controller interface { | ||
| 5 | |||
| 6 | // When implemented, handles the request | ||
| 7 | HandleRequest(c *Context) | ||
| 8 | } | ||
| 9 | |||
| 10 | // The ControllerFunc type is an adapter to allow the use of | ||
| 11 | // ordinary functions as goweb handlers. If f is a function | ||
| 12 | // with the appropriate signature, ControllerFunc(f) is a | ||
| 13 | // Controller object that calls f. | ||
| 14 | type ControllerFunc func(*Context) | ||
| 15 | |||
| 16 | // HandleRequest calls f(c). | ||
| 17 | func (f ControllerFunc) HandleRequest(c *Context) { | ||
| 18 | f(c) | ||
| 19 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
beego/core/model.go
deleted
100644 → 0
File mode changed
beego/core/router.go
deleted
100644 → 0
| 1 | package beego | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "regexp" | ||
| 5 | "strings" | ||
| 6 | ) | ||
| 7 | |||
| 8 | /* | ||
| 9 | Route | ||
| 10 | */ | ||
| 11 | |||
| 12 | // Represents a single route mapping | ||
| 13 | type Route struct { | ||
| 14 | pattern string | ||
| 15 | parameterKeys ParameterKeyMap | ||
| 16 | extension string | ||
| 17 | Path string | ||
| 18 | Controller Controller | ||
| 19 | MatcherFuncs []RouteMatcherFunc | ||
| 20 | } | ||
| 21 | |||
| 22 | func (r *Route) String() string { | ||
| 23 | return "{Route:'" + r.Path + "'}" | ||
| 24 | } | ||
| 25 | |||
| 26 | // Makes a new route from the given path | ||
| 27 | func makeRouteFromPath(path string) *Route { | ||
| 28 | |||
| 29 | // get the path segments | ||
| 30 | segments := getPathSegments(path) | ||
| 31 | regexSegments := make([]string, len(segments)) | ||
| 32 | |||
| 33 | // prepare the parameter key map | ||
| 34 | var paramKeys ParameterKeyMap = make(ParameterKeyMap) | ||
| 35 | |||
| 36 | var extension string | ||
| 37 | |||
| 38 | // pull out any dynamic segments | ||
| 39 | for index, _ := range segments { | ||
| 40 | |||
| 41 | if isDynamicSegment(segments[index]) { | ||
| 42 | |||
| 43 | // e.g. {id} | ||
| 44 | |||
| 45 | paramKeys[strings.Trim(segments[index], "{}")] = index | ||
| 46 | regexSegments[index] = ROUTE_REGEX_PLACEHOLDER | ||
| 47 | |||
| 48 | } else if isExtensionSegment(segments[index]) { | ||
| 49 | |||
| 50 | // e.g. .json | ||
| 51 | extension = segments[index] | ||
| 52 | |||
| 53 | // trim off the last space (we don't need it) | ||
| 54 | regexSegments = regexSegments[0 : len(regexSegments)-1] | ||
| 55 | |||
| 56 | } else { | ||
| 57 | |||
| 58 | // e.g. "groups" | ||
| 59 | |||
| 60 | regexSegments[index] = segments[index] | ||
| 61 | |||
| 62 | } | ||
| 63 | |||
| 64 | } | ||
| 65 | |||
| 66 | patternString := "/" + strings.Join(regexSegments, "/") | ||
| 67 | |||
| 68 | // return a new route | ||
| 69 | var route *Route = new(Route) | ||
| 70 | route.pattern = patternString | ||
| 71 | route.extension = extension | ||
| 72 | route.parameterKeys = paramKeys | ||
| 73 | route.Path = path | ||
| 74 | route.Controller = nil | ||
| 75 | return route | ||
| 76 | |||
| 77 | } | ||
| 78 | |||
| 79 | // Gets the parameter values for the route from the specified path | ||
| 80 | func (route *Route) getParameterValueMap(path string) ParameterValueMap { | ||
| 81 | return getParameterValueMap(route.parameterKeys, path) | ||
| 82 | } | ||
| 83 | |||
| 84 | // Checks whether a path matches a route or not | ||
| 85 | func (route *Route) DoesMatchPath(path string) bool { | ||
| 86 | |||
| 87 | match, error := regexp.MatchString(route.pattern, path) | ||
| 88 | |||
| 89 | if error == nil { | ||
| 90 | if match { | ||
| 91 | |||
| 92 | if len(route.extension) > 0 { | ||
| 93 | |||
| 94 | // make sure the extensions match too | ||
| 95 | return strings.HasSuffix(strings.ToLower(path), strings.ToLower(route.extension)) | ||
| 96 | |||
| 97 | } else { | ||
| 98 | return match | ||
| 99 | } | ||
| 100 | |||
| 101 | } else { | ||
| 102 | |||
| 103 | return false | ||
| 104 | |||
| 105 | } | ||
| 106 | |||
| 107 | } | ||
| 108 | |||
| 109 | // error :-( | ||
| 110 | return false | ||
| 111 | |||
| 112 | } | ||
| 113 | |||
| 114 | // Checks whether the context for this request matches the route | ||
| 115 | func (route *Route) DoesMatchContext(c *Context) bool { | ||
| 116 | |||
| 117 | // by default, we match | ||
| 118 | var match bool = true | ||
| 119 | |||
| 120 | if len(route.MatcherFuncs) > 0 { | ||
| 121 | |||
| 122 | // there are some matcher functions, so don't automatically | ||
| 123 | // match by default - let the matchers decide | ||
| 124 | match = false | ||
| 125 | |||
| 126 | // loop through the matcher functions | ||
| 127 | for _, f := range route.MatcherFuncs { | ||
| 128 | |||
| 129 | // modify 'match' based on the result of the matcher function | ||
| 130 | switch f(c) { | ||
| 131 | case NoMatch: | ||
| 132 | match = false | ||
| 133 | case Match: | ||
| 134 | match = true | ||
| 135 | } | ||
| 136 | |||
| 137 | } | ||
| 138 | |||
| 139 | } | ||
| 140 | |||
| 141 | // return the result | ||
| 142 | return match | ||
| 143 | |||
| 144 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
beego/core/view.go
deleted
100644 → 0
File mode changed
beego/helper/config.go
deleted
100644 → 0
| 1 | package helper | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "json" | ||
| 5 | "io/ioutil" | ||
| 6 | "log" | ||
| 7 | ) | ||
| 8 | |||
| 9 | var config map[string]string | ||
| 10 | |||
| 11 | func ReadConfig(filename string) { | ||
| 12 | contents, err := ioutil.ReadFile(filename) | ||
| 13 | if err != nil { | ||
| 14 | log.Exitf("Impossible to read %s", filename, err) | ||
| 15 | } | ||
| 16 | data, err := json.Decode(string(contents)) | ||
| 17 | if err != nil { | ||
| 18 | log.Exitf("Can't parse %s as JSON", filename, err) | ||
| 19 | } | ||
| 20 | config = map[string]string{ } | ||
| 21 | for key, value := range data.(map[string]interface{ }) { | ||
| 22 | config[key] = value.(string) | ||
| 23 | } | ||
| 24 | } | ||
| 25 | |||
| 26 | func GetConfig(key string) string { | ||
| 27 | return config[key]; | ||
| 28 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
beego/helper/page.go
deleted
100644 → 0
File mode changed
beego/orm/activerecord.go
deleted
100644 → 0
File mode changed
beego/server/fcgi.go
deleted
100644 → 0
File mode changed
beego/server/server.go
deleted
100644 → 0
examples/blog/blog.go
deleted
100644 → 0
| 1 | // Copyright 2011 Google Inc. All rights reserved. | ||
| 2 | // Use of this source code is governed by the Apache 2.0 | ||
| 3 | // license that can be found in the LICENSE file. | ||
| 4 | |||
| 5 | package guestbook | ||
| 6 | |||
| 7 | import ( | ||
| 8 | "../../beego" | ||
| 9 | ) | ||
| 10 | |||
| 11 | func init() { | ||
| 12 | beego.C.loadconfig() | ||
| 13 | } | ||
| 14 | |||
| 15 | func main() { | ||
| 16 | app:=beego.App | ||
| 17 | app.Run() | ||
| 18 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
examples/blog/configs/app.yaml
deleted
100644 → 0
examples/blog/controller/user.go
deleted
100644 → 0
examples/blog/model/user.go
deleted
100644 → 0
examples/hello/hello.go
deleted
100644 → 0
tools/generator.go
deleted
100644 → 0
File mode changed
tools/scaffolding.go
deleted
100644 → 0
File mode changed
-
Please register or sign in to post a comment