This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RewriteEngine on | |
| RewriteCond $1 !^(index\.php) | |
| RewriteRule ^(.*)$ index.php/$1 [L] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| include("toro.php"); | |
| // Domain object, not included, just for following along | |
| include("domain/user.php"); | |
| class V1UserCreateHandler extends ToroHandler { | |
| private function fail($error_type="") { | |
| echo json_encode(array("success" => false, "error_type" => $error_type)); | |
| exit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Toro::serve(array( | |
| "/" => "SplashHandler", | |
| "/catalog/page/:number" => "CatalogHandler", | |
| "/product/:alpha" => "ProductHandler", | |
| "/manufacturer/:string" => "ManufacturerHandler" | |
| )); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class ExampleHandler { | |
| function get() {} | |
| function post() {} | |
| function get_xhr() {} | |
| function post_xhr() {} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Fired for 404 errors | |
| ToroHook::add("404", function() {}); | |
| // Before/After callbacks in order | |
| ToroHook::add("before_request", function() {}); | |
| ToroHook::add("before_handler", function() {}); | |
| ToroHook::add("after_handler", function() {}); | |
| ToroHook::add("after_request", function() {}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| "net/http" | |
| "net/http/httputil" | |
| "net/url" | |
| ) | |
| func main() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.acme; | |
| import com.prevoty.*; | |
| import javax.servlet.ServletException; | |
| import javax.servlet.http.HttpServlet; | |
| import javax.servlet.http.HttpServletRequest; | |
| import javax.servlet.http.HttpServletResponse; | |
| import java.io.IOException; | |
| import java.io.PrintWriter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type ( | |
| RPC struct { | |
| cache map[string]string | |
| requests *Requests | |
| mu *sync.RWMutex | |
| } | |
| CacheItem struct { | |
| Key string | |
| Value string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func NewRPC() *RPC { | |
| return &RPC{ | |
| cache: make(map[string]string), | |
| requests: &Requests{}, | |
| mu: &sync.RWMutex{}, | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (r *RPC) Get(key string, resp *CacheItem) (err error) { | |
| r.mu.RLock() | |
| defer r.mu.RUnlock() | |
| cacheValue, found := r.cache[key] | |
| if !found { | |
| return NotFoundError | |
| } |