This file contains 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) Delete(key string, ack *bool) error { | |
r.mu.Lock() | |
defer r.mu.Unlock() | |
var found bool | |
_, found = r.cache[key] | |
if !found { | |
return NotFoundError | |
} |
This file contains 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) Put(item *CacheItem, ack *bool) error { | |
r.mu.Lock() | |
defer r.mu.Unlock() | |
r.cache[item.Key] = item.Value | |
*ack = true | |
r.requests.Put++ | |
return nil | |
} |
This file contains 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 | |
} |
This file contains 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 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 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 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 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 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 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" | |
)); |