使⽤Laravel 8 PHP主流框架打造 RESTful API
API RESTful API 是什麼 Representational state transfer (REST) 表現層狀態轉換 Client Server REQUEST RESPONSE GET https://localhost/api/v1/articles/1 HTTP STATUS : 200 OK HTTP 協定 HTTP VERBS. URL. HTTP 14:07:22" } } 201 CREATED https://localhost/api/v1/articles Headers Headers Body Body REQUEST RESPONSE JSON Accept : application/json Content-Type : application/json Content-Type : application/json 14:07:22" } } 201 CREATED Request Response { "title": "我是標題⽂字", "content": "我是內容" } 查看單⼀資源 GET https://localhost/api/v1/articles/1 Response Request { "data": { "id":0 码力 | 22 页 | 3.41 MB | 1 年前3Comprehensive Rust(繁体中文)
("Checking {:#}", command.url); let response = client.get(command.url.clone()).send()?; if !response.status().is_success() { return Err(Error::BadResponse(response.status().to_string())); } let mut Vec::new(); if !command.extract_links { return Ok(link_urls); } let base_url = response.url().to_owned(); let body_text = response.text()?; let document = Html::parse_document(&body_text); let selector = ("Checking {:#}", command.url); let response = client.get(command.url.clone()).send()?; if !response.status().is_success() { return Err(Error::BadResponse(response.status().to_string())); } let mut0 码力 | 358 页 | 1.41 MB | 10 月前3julia 1.10.10
specified, a temporary path. The output can also be an IO handle, in which case the body of the response is streamed to that handle and the handle is returned. If output is a command, the command is run =, ] [ throw = true, ] [ downloader = , ] [ interrupt = , ] ) -> Union{Response, RequestError} url :: AbstractString input :: Union{AbstractString, AbstractCmd, IO} output :: Make a request to the given url, returning a Response object capturing the status, headers and other information about the response. The body of the response is written to output if specified and discarded 0 码力 | 1692 页 | 6.34 MB | 3 月前3Julia 1.10.9
specified, a temporary path. The output can also be an IO handle, in which case the body of the response is streamed to that handle and the handle is returned. If output is a command, the command is run =, ] [ throw = true, ] [ downloader = , ] [ interrupt = , ] ) -> Union{Response, RequestError} url :: AbstractString input :: Union{AbstractString, AbstractCmd, IO} output :: Make a request to the given url, returning a Response object capturing the status, headers and other information about the response. The body of the response is written to output if specified and discarded 0 码力 | 1692 页 | 6.34 MB | 3 月前3Julia 1.11.4
ScopedValue(:GUEST) function serve(request, response) level = isAdmin(request) ? :ADMIN : :GUEST with(LEVEL => level) do Threads.@spawn handle(request, response) end end function open(connection::Database) == :ADMIN error("Access disallowed") end # ... open connection end function handle(request, response) # ... open(Database(#=...=#))CHAPTER 50. SCOPED VALUES 1132 # ... end 50.2 Idioms Unshare specified, a temporary path. The output can also be an IO handle, in which case the body of the response is streamed to that handle and the handle is returned. If output is a command, the command is run0 码力 | 2007 页 | 6.73 MB | 3 月前3Julia 1.11.5 Documentation
ScopedValue(:GUEST) function serve(request, response) level = isAdmin(request) ? :ADMIN : :GUEST with(LEVEL => level) do Threads.@spawn handle(request, response) end end function open(connection::Database) == :ADMIN error("Access disallowed") end # ... open connection end function handle(request, response) # ... open(Database(#=...=#))CHAPTER 50. SCOPED VALUES 1132 # ... end 50.2 Idioms Unshare specified, a temporary path. The output can also be an IO handle, in which case the body of the response is streamed to that handle and the handle is returned. If output is a command, the command is run0 码力 | 2007 页 | 6.73 MB | 3 月前3Julia 1.11.6 Release Notes
ScopedValue(:GUEST) function serve(request, response) level = isAdmin(request) ? :ADMIN : :GUEST with(LEVEL => level) do Threads.@spawn handle(request, response) end end function open(connection::Database) == :ADMIN error("Access disallowed") end # ... open connection end function handle(request, response) # ... open(Database(#=...=#))CHAPTER 50. SCOPED VALUES 1132 # ... end 50.2 Idioms Unshare specified, a temporary path. The output can also be an IO handle, in which case the body of the response is streamed to that handle and the handle is returned. If output is a command, the command is run0 码力 | 2007 页 | 6.73 MB | 3 月前3julia 1.13.0 DEV
ScopedValue(:GUEST) function serve(request, response) level = isAdmin(request) ? :ADMIN : :GUEST with(LEVEL => level) do Threads.@spawn handle(request, response) end end function open(connection::Database) == :ADMIN error("Access disallowed") end # ... open connection end function handle(request, response) # ... open(Database(#=...=#))CHAPTER 51. SCOPED VALUES 1181 # ... end 51.2 Idioms Unshare specified, a temporary path. The output can also be an IO handle, in which case the body of the response is streamed to that handle and the handle is returned. If output is a command, the command is run0 码力 | 2058 页 | 7.45 MB | 3 月前3Julia 1.12.0 RC1
ScopedValue(:GUEST) function serve(request, response) level = isAdmin(request) ? :ADMIN : :GUEST with(LEVEL => level) do Threads.@spawn handle(request, response) end end function open(connection::Database) == :ADMIN error("Access disallowed") end # ... open connection end function handle(request, response) # ... open(Database(#=...=#))CHAPTER 51. SCOPED VALUES 1179 # ... end 51.2 Idioms Unshare specified, a temporary path. The output can also be an IO handle, in which case the body of the response is streamed to that handle and the handle is returned. If output is a command, the command is run0 码力 | 2057 页 | 7.44 MB | 3 月前3Julia 1.12.0 Beta4
ScopedValue(:GUEST) function serve(request, response) level = isAdmin(request) ? :ADMIN : :GUEST with(LEVEL => level) do Threads.@spawn handle(request, response) end end function open(connection::Database) == :ADMIN error("Access disallowed") end # ... open connection end function handle(request, response) # ... open(Database(#=...=#))CHAPTER 51. SCOPED VALUES 1178 # ... end 51.2 Idioms Unshare specified, a temporary path. The output can also be an IO handle, in which case the body of the response is streamed to that handle and the handle is returned. If output is a command, the command is run0 码力 | 2057 页 | 7.44 MB | 3 月前3
共 22 条
- 1
- 2
- 3